简体   繁体   English

DropDownList的SelectedIndexChanged事件未触发

[英]SelectedIndexChanged event of DropDownList is not fired

ASPX FILE contain DropDown as Follows: ASPX FILE包含DropDown ,如下所示:

< asp:DropDownList ID="drpDist" runat="server" CssClass="dropDownStyle" OnSelectedIndexChanged="drpDist_SelectedIndexChanged" TabIndex="6">

In ASPX.CS FILE ASPX.CS FILE

protected void drpDist_SelectedIndexChanged(object sender, EventArgs e)
{
}

Please Help me.I can't get why it is not working. 请帮助我。我不明白为什么它不起作用。

使用财产

AutoPostBack="True"

you need to set AutoPostBack="true" 您需要设置AutoPostBack="true"

<asp:DropDownList ID="drpDist" runat="server" AutoPostBack="true">

when you set that property as true, a postback to the server automatically occurs whenever the user changes the selection of the list 当您将该属性设置为true时,只要用户更改列表的选择,就会自动回发到服务器

You need to set the AutoPostBack="True" property. 您需要设置AutoPostBack="True"属性。 This will make the page to postback automatically hence firing your event. 这将使页面自动回发,从而触发您的事件。

设置AutoPostBack="true"

< asp:DropDownList ID="drpDist" runat="server" AutoPostBack="true" CssClass="dropDownStyle" OnSelectedIndexChanged="drpDist_SelectedIndexChanged" TabIndex="6">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM