我使用了两个DropDownList进行相关级联,现在有一个问题没有解决,希望高人给一些参考。进行级联时,首次加载没有问题,但当将上面的DropDownList的TextField改变时,问题就出现了。
if (type_1ddl.SelectedItem.Text != "商品大类")
{
Type_1 t = Type_1Manager.getByTypeName(type_1ddl.SelectedItem.Text);
int typeid1 = t.Typeid_1;
type_2ddl.DataSource = Type_2Manager.GetType_2ByTypeid_1(typeid1);
type_2ddl.DataTextField = "typename";
type_2ddl.DataValueField = "typeid_2";
type_2ddl.DataBind();
}
DropDownList2本身使用 <asp:ListItem></asp:ListItem>为其指定了相应的文本,当DropDownList1进行改变时,我想只保留DropDownList2的该文本。
if (type_1ddl.SelectedItem.Text != "商品大类")
{
Type_1 t = Type_1Manager.getByTypeName(type_1ddl.SelectedItem.Text);
int typeid1 = t.Typeid_1;
type_2ddl.DataSource = Type_2Manager.GetType_2ByTypeid_1(typeid1);
type_2ddl.DataTextField = "typename";
type_2ddl.DataValueField = "typeid_2";
type_2ddl.DataBind();
}
DropDownList2本身使用 <asp:ListItem></asp:ListItem>为其指定了相应的文本,当DropDownList1进行改变时,我想只保留DropDownList2的该文本。
解决方案 »
- asp.net 母版页与iframe的具体区别
- 关于正则的一个问题
- 散分问题
- 各位老大,我用NHibernate时候总是出现:Can not add assembly named: Enterprise的错误,是什么原因阿??!!
- “+”号怎么会变连接符呢?我要的是两个数字的数学运算????
- alert语句:未结束的字符串常量。为什么?
- "点击增加按钮时,弹出窗口后,父页面什么都没有显示"的问题
- 【mvc初学者求教!】mvc4+EF同一视图中查询和增加
- 关于索引服务(indexing service)
- 思归大哥,我是上午你帮我解答Session存储dataSet的,我想在问你一下,我动态添加进去后,我怎么删除掉(在存数据库以前)?
- FileUpload上传的最大值是多少
- gridview 绑定datatable 做购物车 在购物车界面点击删除出问题
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlLB" runat="server" Width="15%" AutoPostBack="True" OnSelectedIndexChanged="ddlLB_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="ddlChild" runat="server" Width="20%">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</div>
protected void ddlLB_SelectedIndexChanged(object sender, EventArgs e)
{
if(this.ddlLB.SelectedValue!=null)
{
BindChild(this.ddlLB.SelectedValue);
}
}
然后在 父级的OnSelectedIndexChanged 事件中 根据 选中的父级ID 初始化 子级下拉框列表(可能需要一个查询函数)