0

I got the following structure in my design:

UpdatePanel, within it an AjaxTabContainer, within it an AjaxTabPanel, within it an ASP FormView and finally within it a Drop Down List

My application is made with a 3-tier architecture and my drop down list's data source is actually a Data Table that is returned by the Business Logic Class.

My problem:

  • My drop down list doesn't show any data after the page is loaded.

My trials:

  • I created two events in my drop down list "OnDataBound" and "OnPreRender" to check where i lose my data.

  • In debug mode, on data bind i found that the list collection for the drop down list exists

  • However, on pre-render the drop down list shows that "No Enumerations Exist" and no collection exists.

My Code:

I have the following design for a 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>

Code Behind:

     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
    }
user3340627
  • 3,023
  • 6
  • 35
  • 80

1 Answers1

0

I found the solution in part of the answer here by Kb.

I added the bind of the DDL to the FormView Data Bound event and it worked fine.

Community
  • 1
  • 1
user3340627
  • 3,023
  • 6
  • 35
  • 80