下拉列表选定索引更改在更新面板中不起作用 [英] Drop Down List Selected Index changed not working in Update panel

查看:17
本文介绍了下拉列表选定索引更改在更新面板中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 UpdatePanel_2 中有一个下拉列表,当在 UpdatePanel_1 中单击 Button_1 时它会被填充.

I have a drop down list in UpdatePanel_2, it gets populated when Button_1 is clicked in UpdatePanel_1.

我的 ddlist 标记是,

My ddlist markup is,

<asp:DropDownList id="drop1" runat="server"  EnableViewState="true" AutoPostBack="true" OnSelectedIndexChanged="Drop1_SelectedIndexChanged" />

那么后面的代码是,

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

我也尝试将 AutoPostback=true 放到我的 DropDownList 中,但仍然没有成功.

我还添加了触发器来更新面板 2 但没有增益,

I also added triggre to update panel 2 but no gain,

       <Triggers>
    <asp:AsyncPostbackTrigger ControlID="drop1" EventName="SelectedIndexChanged" />
</Triggers>

我正在使用按钮而不是页面加载方法填充 DropDownList,请在回答前阅读.谢谢

推荐答案

检查数据以填充 Page_Load 事件中的 DropDownList 并始终检查 IspostBack:

Check the data to populate the DropDownList in the Page_Load event and always check IspostBack:

if(!IsPostBack)
{
 //DropDownList configuration
}

使用EnableViewState:

 <asp:DropDownList ID="ddlAddDepPlans" runat="server" AutoPostBack="true" EnableViewState="true" />

希望对你有帮助.

这篇关于下拉列表选定索引更改在更新面板中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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