Drop Down List Selected Index changed not working in Update panel(下拉列表选定索引更改在更新面板中不起作用)
问题描述
我在 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" />
希望对你有帮助.
这篇关于下拉列表选定索引更改在更新面板中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:下拉列表选定索引更改在更新面板中不起作用


基础教程推荐
- JSON.NET 中基于属性的类型解析 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01