【发布时间】:2014-05-24 19:43:39
【问题描述】:
我的 asp.net 网页上有一个简单的 DropDownList:
看起来像这样:
<asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="FriendList" runat="server"
EnableViewState="False" Height="30px" Width="10%"
OnTextChanged="FriendListSwitch" AutoPostBack="True">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSend" />
</Triggers>
<--!The button is a stub, I actually need to load it from the codebehind-->
</asp:UpdatePanel>
然后我有这样的代码隐藏:
void OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
{
FriendList.Items.Add(new ListItem(String.Format("{0}", item.Jid.User), ""));
FriendList.DataBind();
}
在调试时,我可以看到“FriendList”正在被填充,并且“btnSend”正在被点击。
然而我的 DropDownList 并没有自动填充,它只是保持空白,为什么不刷新?
编辑:我宁愿删除按钮并将其替换为
void OnRosterEnd(object sender)
{
UpdatePanel5.Update();
}
但后来我不断得到
The Update method can only be called on UpdatePanel with ID 'X' before Render.
已解决,DataBind() 只在我的 Page_Load 中工作。
【问题讨论】:
标签: c# asp.net drop-down-menu webforms refresh