Mat*_*ics 9 c# updatepanel webforms
我在UpdatePanel_2中有一个下拉列表,当在UpdatePanel_1中单击Button_1时,它会被填充.
我的ddlist标记是,
<asp:DropDownList id="drop1" runat="server" EnableViewState="true" AutoPostBack="true" OnSelectedIndexChanged="Drop1_SelectedIndexChanged" />
Run Code Online (Sandbox Code Playgroud)
然后代码背后是,
protected void Drop1_SelectedIndexChanged(object sender, EventArgs e)
{ }
Run Code Online (Sandbox Code Playgroud)
我也尝试将AutoPostback = true放到我的DropDownList中,仍然没有成功.
我还添加了triggre来更新面板2,但没有增益,
<Triggers>
<asp:AsyncPostbackTrigger ControlID="drop1" EventName="SelectedIndexChanged" />
</Triggers>
Run Code Online (Sandbox Code Playgroud)
我在使用按钮填充DropDownList而不是PAGE LOAD METHOD请在回答之前阅读.谢谢
Nee*_*bey 11
检查数据来填充DropDownList的Page_Load事件,并经常检查IspostBack:
if(!IsPostBack)
{
//DropDownList configuration
}
Run Code Online (Sandbox Code Playgroud)
用途EnableViewState:
<asp:DropDownList ID="ddlAddDepPlans" runat="server" AutoPostBack="true" EnableViewState="true" />
Run Code Online (Sandbox Code Playgroud)
希望它能帮到你.
我遇到过同样的问题.我的问题是我的ListItems的值都是一样的:D
<asp:DropDownList ID="ddlFilterLogins" runat="server" Visible="true" AutoPostBack="true">
<asp:ListItem Value="0" Text="All"></asp:ListItem>
<asp:ListItem Value="0" Text="Some"></asp:ListItem>
<asp:ListItem Value="0" Text="Some more"></asp:ListItem>
</asp:DropDownList>
Run Code Online (Sandbox Code Playgroud)
它应该是这样的:
<asp:DropDownList ID="ddlFilterLogins" runat="server" Visible="true" AutoPostBack="true">
<asp:ListItem Value="0" Text="All"></asp:ListItem>
<asp:ListItem Value="1" Text="Some"></asp:ListItem>
<asp:ListItem Value="2" Text="Some more"></asp:ListItem>
</asp:DropDownList>
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.这有时候很难找到:)
| 归档时间: |
|
| 查看次数: |
50395 次 |
| 最近记录: |