我将在服务器端预先填充我的下拉列表。我只希望在父控件发生更改时触发级联下拉菜单。
问问题
592 次
1 回答
0
从代码隐藏中填充您的父 ListBox,并将其“autopostback”属性设置为true
. 放OnSelectedIndexChanged="PopulateChildListBox"
将子ListBox放入UpdatePanel中,并将父ListBox与Updatepanel相关联
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lbParent" />
</Triggers>
<ContentTemplate>
<asp:ListBox ID="lbChild" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
在您的代码隐藏中,让“PopulateChildListBox”方法填充子 ListBox
protected void PopulateChildListBox(object sender, EventArgs e)
{
// Get the data for the child listbox
lbChildListBox.DataBind();
}
因此,您的子列表框仅在父列表框更改时才更新其内容(通过 Asp.Net AJAX)。
于 2009-10-19T11:49:53.337 回答