我的设计中有以下结构:
UpdatePanel
,其中AjaxTabContainer
,AjaxTabPanel
,ASP FormView
,最后Drop Down List
我的应用程序采用3层架构,我的下拉列表的数据源实际上是业务逻辑类返回的数据表。
我的问题:
我的试验
我在下拉列表“OnDataBound”和“OnPreRender”中创建了两个事件来检查我丢失数据的位置。
在调试模式下,在数据绑定上,我发现下拉列表的列表集合存在
但是,在预渲染时,下拉列表会显示“No Enumerations Exists”并且不存在任何集合。
我的代码:
我有一个TabControl的设计
<asp:UpdatePanel ID="UpdtPnlRefugeeInfo" runat="server">
<ContentTemplate>
<ajaxcontrol:TabContainer ID="tabInfoPanel" runat="server" Style="visibility: visible;">
<ajaxcontrol:TabPanel runat="server" ID="PnlBasicInfo">
<HeaderTemplate>
Basic Info
</HeaderTemplate>
<ContentTemplate>
<asp:FormView runat="server" ID="FormViewBasicInfo" DataSourceID="SQLInfoDashboard" OnDataBound="FormViewBasicInfo_DataBound" Width="100%">
<ItemTemplate>
<table runat="server" id="EditTable" style="width: 100%">
<tr>
<td class="mytdlabel">
<asp:Label CssClass="mylabel" runat="server" ID="lblGender" Text="Gender"></asp:Label>
</td>
<td class="mytddata">
<asp:DropDownList CssClass="mydropdown" ID="DDLGender" runat="server" OnDataBound="DDLGender_DataBound" OnPreRender="DDLGender_PreRender"></asp:DropDownList>
</td>
代码背后:
protected void Page_Load(object sender, EventArgs e)
{
BLREOptions = new BusinessLogic.BLREOptions(); // this is my business logic class
DDLGender = ((DropDownList)FormViewBasicInfo.FindControl("DDLGender"));
tabInfoPanel.ActiveTab = tabInfoPanel.Tabs[0];
FormViewBasicInfo.DataBind();
LoadDDLs();
}
protected void LoadDDLs()
{
DDLGender.DataSource = BLREOptions.getGenderList();
DDLGender.DataValueField = "OptionValue";
DDLGender.DataTextField = "OptionName";
DDLGender.DataBind();
}
protected void DDLGender_DataBound(object sender, EventArgs e)
{
// The List is found here
}
protected void DDLGender_PreRender(object sender, EventArgs e)
{
// the list is not found here
}