我有一个关于过滤器的简单问题.
我有4个下拉列表,用于从 MySQL数据库表中过滤我的Web应用程序中的数据.
已选择第一个下拉列表,仅显示一个project_id,但其他下拉列表显示数据库中的所有可能值 – 这是我到目前为止所做的.
我有4个下拉列表,用于从 MySQL数据库表中过滤我的Web应用程序中的数据.
已选择第一个下拉列表,仅显示一个project_id,但其他下拉列表显示数据库中的所有可能值 – 这是我到目前为止所做的.
但我想只显示所选特定项目的数据值.
解决方法
查看以下链接以填充级联下拉列表.
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
码:
<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>
//代码背后
protected void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
{
//您的代码绑定第一个下拉列表
} } 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 } }
原文地址:https://www.jb51.cc/aspnet/245586.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。