DropDownList二級無リフレッシュ機能実現
2091 ワード
DropDownList
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
<Triggers>
<!-- SelectedIndexChanged OnSelectedIndexChanged -->
<asp:AsyncPostBackTrigger ControlID="sclassbig" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:DropDownList ID="sclassbig" AutoPostBack="true" OnSelectedIndexChanged="select_change"
runat="server">
<asp:ListItem> </asp:ListItem>
<asp:ListItem> </asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="sclasssml" AutoPostBack="true" runat="server">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
cs
/// <summary>
///
/// </summary>
protected void smlbd()
{
string bigStr = " ";//
DataTable dt = getSql("select sclasssml from sclass where sclassbig='"+bigStr+"'");
sclasssml.DataSource = dt;
sclasssml.DataTextField = "sclasssml";
sclasssml.DataValueField = "sclasssml";
sclasssml.DataBind();
}
/// <summary>
///
/// </summary>
protected void select_change(object sender, EventArgs e)
{
string bigStr = sclassbig.SelectedValue;
DataTable dt = getSql("select sclasssml from sclass where sclassbig='" + bigStr + "'");
sclasssml.DataSource = dt;
sclasssml.DataTextField = "sclasssml";
sclasssml.DataValueField = "sclasssml";
sclasssml.DataBind();
//sclasssml.Items.Insert(0, "-- --");
//sclasssml.Items[0].Value = "0";
}