Link to home
Start Free TrialLog in
Avatar of jgroetch
jgroetchFlag for United States of America

asked on

DropDownList does not update when placed inside UpdatePanel - VS2008

Basically my DropDownList does not update when placed inside UpdatePanel; however, both my HyperLink and Label objects do update fine. If I do a hard refresh in my browser, then I can force the dropdown's to update.

The main difference is that my DropDown's are using an ObjectDataSource to pull the data records. Does that have something to do with it ?

I added UpdatePanelHeader.Update(); to my ContentPlaceHolder1_Load() to no avail.

Here's a code snippet attached:

 

Any advise please ?

Bob
<asp:UpdatePanel ID="UpdatePanelHeader" UpdateMode="Conditional" runat="server">
  <ContentTemplate>
                                                             
    <table align="center" style="vertical-align:top; text-align:center; table-layout: auto;">
    <tr>
 
          <td>       <!-- Hyperlink and Label work fine; The Text attrib gets programmatically changed in .cs code-behind -->
              <asp:HyperLink ID="lnkSubmitOrders" Text="" NavigateUrl="javascript:SubmitOrdersForm('NEW')" runat="server" ></asp:HyperLink>                           
          </td>
 
          <td><asp:Label ID="lblMatching" Text="orders matching filter:" runat="server" /></td> 
 
<td>   <!-- DropDown's are not updating inside this panel -->
 
    <asp:DropDownList ID="drpFilterList" DataSourceID="ObjectDataSourceFilterList" DataValueField="filter_id" DataTextField="f_name" AppendDataBoundItems="true" runat="server" 
            AutoPostBack="True" OnSelectedIndexChanged="drpFilterList_SelectedIndexChanged" EnableViewState="true" >
         <asp:ListItem Selected="True" Text="Default" Value="0" />
 
    </asp:DropDownList>
 
    <asp:DropDownList ID="DrpStatusList" DataSourceID="ObjectDataSourceStatusList" AutoPostBack="True" DataTextField="status" DataValueField="status" AppendDataBoundItems="true" runat="server" OnSelectedIndexChanged="DrpStatusList_SelectedIndexChanged" >
                                    <asp:ListItem Value="0" Selected="true">All</asp:ListItem>
                                    <asp:ListItem Value="LiveOrders" Selected="False">LiveOrders</asp:ListItem>
    </asp:DropDownList>
</td>
 
 
  </ContentTemplate>                       
 
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="TimerHeader" EventName="" />
    </Triggers>
 
     </asp:UpdatePanel>
 
   </tr>
 </table>

Open in new window

Avatar of Juan_Barrera
Juan_Barrera
Flag of New Zealand image

Hi Bob,

Do you want th DDLs to update when you change it's selected item?
If so, you need to call the update method in, for example, drpFilterList_SelectedIndexChanged.
Avatar of jgroetch

ASKER

No. The DDL should be populated with a list of statuses that I pull from a table. The list is only showing the two values ("All", "Live Orders")  initiated in my aspx page as follows :

<asp:DropDownList ID="DrpStatusList" DataSourceID="ObjectDataSourceStatusList"  AutoPostBack="True" ... > 

                               <asp:ListItem Value="0" Selected="true">All</asp:ListItem>
                               <asp:ListItem Value="LiveOrders" Selected="False">LiveOrders</asp:ListItem>

          </asp:DropDownList>

It only shows the rest of the values upon a hard refresh. I even try to rebind in my .cs code :

        ObjectDataSourceStatusList.DataBind();
        UpdatePanelHeader.Update();

I don't understand...

Thanks,
Bob
ASKER CERTIFIED SOLUTION
Avatar of Juan_Barrera
Juan_Barrera
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Juan,
Thanks for your response. I had the same thought previously and noticed that my latest version of the aspx page already had what you suggested; that is, the ending UpdatePanel tag was in fact after the table.
Then I noticed I also had another table one level above what you pointed out.

Now I just tried to put my UpdatePanel way up top above all table defs - and even above the first <div> within this master page.

Perhaps my bigger problem is that this is the MasterPage and my child page also has an UpdatePanel in it.

Please note that this is working just fine (and I update the actual Text property in my .cs code) :

   <asp:HyperLink ID="lnkSubmitOrders" ForeColor="red" Font-Bold="true" Font-Size="Large" Text=""  NavigateUrl="javascript:SubmitOrdersForm('NEW')" runat="server" >
    </asp:HyperLink>

Thanks,
Bob


Turns out that my real problem was a bug I created while trying to remove the client name and user id in the query string (and use my server vars instead).
So as you can see below in the <SelectParameter> tag, if I don't have a query string param in the URL of my application, then there's no way my Obj Data Source is gonna pull the records I need for the DropDown.

Okay, now how do I assign points here in this case ?

Perhaps you can tell me if I can use a server var in place of the QueryStringParameter ?

Thanks,
bob
<asp:ObjectDataSource ID="ObjectDataSourceStatusList" runat="server" SelectMethod="getDistinctStatus" TypeName="DataSearchComponents">
        <SelectParameters>                        
            <asp:QueryStringParameter QueryStringField="client" Name="client" Type="String" DefaultValue=" " />
            <asp:QueryStringParameter QueryStringField="search_type" Name="search_type" DefaultValue=" " />
        </SelectParameters>
</asp:ObjectDataSource>

Open in new window

Hi Bob,
No problem about the points, you can just close the question  :)

About  server vars, what control is holding the values for "client" and "search_type"? Or the just come from the previous page?