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" />
希望对你有帮助.
这篇关于下拉列表选定索引更改在更新面板中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:下拉列表选定索引更改在更新面板中不起作用
基础教程推荐
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
