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" />
希望对你有帮助.
这篇关于下拉列表选定索引更改在更新面板中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:下拉列表选定索引更改在更新面板中不起作用
基础教程推荐
- 如果条件可以为空 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 将数据集转换为列表 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
