sql >> Base de Datos >  >> RDS >> Mysql

Cómo filtrar los valores de la lista desplegable por otra lista desplegable en ASP.NET, C#

consulte los siguientes enlaces para completar la lista desplegable en cascada.

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown .aspx

http://www.codeproject.com/KB/aspnet/CascadingDropDown.aspx

http://www.aspsnippets.com/Articles /Creación-de-listas-desplegables-en-cascada-en-ASP.Net.aspx

Código:

<table>
    <tr>
        <td>First</td>
        <td><asp:DropDownList ID="DDLFirst" runat="server"  AutoPostBack="true"
                onselectedindexchanged="DDLFirst_SelectedIndexChanged"></asp:DropDownList></td>
    </tr>
    <tr>
        <td>Secord</td>
        <td><asp:DropDownList ID="DDLSecond" runat="server" AutoPostBack="true"
                onselectedindexchanged="DDLSecond_SelectedIndexChanged">
            <asp:ListItem Text="Select" Value="Select"></asp:ListItem>    
            </asp:DropDownList></td>
    </tr>
    <tr>
        <td>Thrid</td>
        <td><asp:DropDownList ID="DDLThird" runat="server"><asp:ListItem Text="Select" Value="Select"></asp:ListItem>    </asp:DropDownList></td>
    </tr>
</table>

// Código detrás de protección vacía Page_Load(object sender, EventArgs e){if (!IsPostBack){// su código para vincular la primera lista desplegable

        }
    }

    protected void DDLFirst_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DDLFirst.SelectedIndex > 0)
        {
            string FirstDDLValue = DDLFirst.SelectedItem.Value;
            // below your code to get the second drop down list value filtered on first selection


        }

    }

    protected void DDLSecond_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DDLSecond.SelectedIndex > 0)
        {
            string SecondDDLValue = DDLSecond.SelectedItem.Value;
            // below your code to get the third drop down list value filtered on Second selection


        }
    }