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

LVL 1
jgroetchAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Juan_BarreraCommented:
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.
0
jgroetchAuthor Commented:
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
0
Juan_BarreraCommented:
Just noticed something in your code, maybe it doesn't have anything to do with your issue, but the markup is not properly formatted, the UpdatePanel should close after the table.
Can you give it a try?

<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>
  
   </tr>
 </table>
 
</ContentTemplate>                       
 
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="TimerHeader" EventName="" />
    </Triggers>
 
     </asp:UpdatePanel>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

jgroetchAuthor Commented:
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


0
jgroetchAuthor Commented:
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

0
Juan_BarreraCommented:
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?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.