How to filter dropdown list values by another dropdown list in ASP.NET, c#

后端 未结 2 1880
独厮守ぢ
独厮守ぢ 2021-01-12 15:58

I have a simple question about filters. I have 4 dropdown lists which filter the data in my web application from MySQL database table. The first dropdown list is already sel

2条回答
  •  隐瞒了意图╮
    2021-01-12 16:13

    check out following links for populating cascading drop down list.

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

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

    http://www.aspsnippets.com/Articles/Creating-Cascading-DropDownLists-in-ASP.Net.aspx

    Code:

    First
    Secord
    Thrid

    // Code behind protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // your code to bind the first drop downlist

            }
        }
    
        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
    
    
            }
        }
    

提交回复
热议问题