dropdownlist选择索引已更改不文件 [英] dropdownlist selected index changed does not file

查看:74
本文介绍了dropdownlist选择索引已更改不文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个下拉列表

 <   asp :DropDownList     runat   =  server    ID   =  DDLState    CssClass   =  txtp  

onselectedindexchanged = DDLState_SelectedIndexChanged

AutoPostBack = True AppendDataBoundItems = < span class =code-keyword> True

< span class =code-attribute> >

< asp:ListItem > 选择州< / asp:ListItem >

< / asp:DropDownList >



我在页面加载时填写它。

我还有一个按钮

 <   asp:按钮    runat   =  server    ID   =  btnsubmit   文字  = 提交    

BackColor = Silver onclick = btnsubmit_Click / >



 受保护  void  btnsubmit_Click(  object  sender,EventArgs e)
{
DDLState.SelectedIndex = 2 ;
}





DDLState_SelectedIndexChanged不会激活。

解决方案

< blockquote class =FQ>

Quote:

你确定吗?

是的, Harshil_Raval 是正确的。



参考 - ListControl.SelectedIndexChanged事件 [ ^ ]。

引用:

当列表控件中的选择在发布到服务器的帖子之间发生变化时,会引发SelectedIndexChanged事件。


I have a dropdownlist

<asp:DropDownList runat="server" ID="DDLState" CssClass="txtp"

        onselectedindexchanged="DDLState_SelectedIndexChanged" 

        AutoPostBack="True" AppendDataBoundItems="True"

       >
      
        <asp:ListItem>Select State</asp:ListItem>
      
    </asp:DropDownList>


I am filling it on pageload.
I have a button also

<asp:Button runat="server" ID="btnsubmit" Text="Submit" 

        BackColor="Silver"  onclick="btnsubmit_Click"  />


protected void btnsubmit_Click(object sender, EventArgs e)
        {
 DDLState.SelectedIndex=2;
}



DDLState_SelectedIndexChangeddoes not fire.

解决方案

Quote:

Are you sure?

Yes, Harshil_Raval is correct.

Refer- ListControl.SelectedIndexChanged Event[^].

Quote:

The SelectedIndexChanged event is raised when the selection from the list control changes between posts to the server.


这篇关于dropdownlist选择索引已更改不文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆