Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

DropDownList does not update when placed inside UpdatePanel - VS2008

Posted on 2008-11-03
7
Medium Priority
?
933 Views
Last Modified: 2013-11-05
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

0
Comment
Question by:jgroetch
  • 3
  • 3
6 Comments
 
LVL 20

Expert Comment

by:Juan_Barrera
ID: 22871476
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
 
LVL 1

Author Comment

by:jgroetch
ID: 22871692
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
 
LVL 20

Accepted Solution

by:
Juan_Barrera earned 750 total points
ID: 22871762
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:jgroetch
ID: 22876910
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
 
LVL 1

Author Comment

by:jgroetch
ID: 22877165
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
 
LVL 20

Expert Comment

by:Juan_Barrera
ID: 22880694
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question