?
Solved

Update Panel not refreshing

Posted on 2011-03-11
5
Medium Priority
?
1,350 Views
Last Modified: 2012-06-27
I have an update panel in a grid template that has a parent and child dropdown.  When the user selects a value from the first, I want the update panel to populate the second dropdown but not refresh the rest of the page.  

I can only get this to even load the second dropdown when I set AutoPostBack="true" in the 1st dropdown.  But this makes it refresh the whole page.  I tried removing that then setting the Update page UpdateMode="Always", but that doesn't do anything at all.  Any idea what I'm doing wrong here?
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
                  <ContentTemplate>                 

                    <cc2:OboutDropDownList ID="ddGenre" runat="server" Width="100"
                         DataSourceID="dsGenres" DataValueField="genre" AutoPostBack="true"
                         DataTextField="genre" AppendDataBoundItems="true">
                          <asp:ListItem Text="...Genre" Value="All" Selected="True"></asp:ListItem>
                    </cc2:OboutDropDownList>

                    <cc2:OboutDropDownList ID="ddSubGenre" runat="server" Width="120"
                         DataSourceID="dsSubGenres" DataValueField="subgenre" DataTextField="subgenre">                                                   
                    </cc2:OboutDropDownList>


                    <!-- Reality Genre / Sub Genre -->
                    <asp:SqlDataSource ID="dsGenres" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:SmashHausConnectionString %>" 
                        SelectCommand="SELECT DISTINCT [genre] FROM [RealityGenres]"></asp:SqlDataSource>        
                
                    <asp:SqlDataSource ID="dsSubGenres" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:SmashHausConnectionString %>" 
                        SelectCommand="SELECT subgenre FROM RealityGenres WHERE genre = @genre ORDER BY subgenre">
                        <SelectParameters>                        
                            <asp:ControlParameter ControlID="ddGenre" DefaultValue="TV" Name="genre" PropertyName="Text" Type="String" />
                        </SelectParameters>	    
                    </asp:SqlDataSource>        

                    </ContentTemplate>
                  </asp:UpdatePanel>

Open in new window

0
Comment
Question by:JT_SIRO
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 35114507
Try UpdateMode="Conditional">
<asp:UpdatePanel id="UpdatePanel1" runat="server" UpdateMode="Conditional"> 

Open in new window


Raj
0
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 168 total points
ID: 35114508
0
 
LVL 14

Assisted Solution

by:dejaanbu
dejaanbu earned 332 total points
ID: 35115530
Hi,

You have to set AutoPostBack="true" in the 1st dropdown.

Then only, it will post back the values to server. Updatepanel will handle the postback and avoids whole page refreshing..

This should work..

Also you can set updatepanel's updatemode to conditional and select triggering events , If you have multiple updates..
0
 

Author Comment

by:JT_SIRO
ID: 35124449
I'm still stuck.  I really don't know what the issue is.  My whole grid still refreshes every time I change ddGenre.  You can put an update panel in a grid template right?  Please help!  I've attached the code for the entire page so you can see.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Purgatory.aspx.cs" Inherits="Admin_Pages_Submissions" MasterPageFile="~/Admin_Pages/mpAdminNEWMENU.master"%>
<%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="cc1" %>
<%@ Register Assembly="obout_Interface" Namespace="Obout.Interface" TagPrefix="cc2" %>
<%@ Register TagPrefix="obout" Namespace="Obout.ComboBox" Assembly="obout_ComboBox" %>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<div id="content" class="xfluid">
    <div class="portlet x12">   
        
    <!-- Form variables for the play/stop buttons -->
    <asp:HiddenField ID="HiddenField1" Value="0" runat="server" />
    <asp:HiddenField ID="hdnComposer" Value="0" runat="server" />
    <asp:HiddenField ID="hdnCD" Value="0" runat="server" />
    <asp:HiddenField ID="hdnLastImagePlayed" Value="0" runat="server" />
    
    <table width="100%">
    <tr>
    <td valign="bottom" style="vertical-align:bottom;">
        <div class="portlet-header-tighter" style="text-align:left; vertical-align:bottom; height:40px; width:205px; background:white;"> 
            <ul class="portlet-tab-nav">
            <!-- Tab Menu -->   
            <li class="portlet-tab-nav-active"><asp:LinkButton ID="LinkButton3" PostBackUrl="Purgatory.aspx" runat="server">Purgatory</asp:LinkButton></li>				
            <li class=""><asp:LinkButton ID="LinkButton2" PostBackUrl="RevisionNotes.aspx" runat="server">Revision Notes</asp:LinkButton></li>
            </ul>
	    </div> <!-- .portlet-header -->		

        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
        <ContentTemplate>  
        &nbsp;<asp:TextBox ID="txtSearch" onfocus="if(this.value=='...Search'){this.value='';};" Text="...Search" runat="server" Width="175" CssClass="textboxstyle3" ></asp:TextBox>
        <asp:Button id="btnSearch" runat="server" Width="70" Text="Search" OnClick="btnSearch_Click" CssClass="btn btn-cart"/> 
        <asp:Button ID="btnReset" runat="server" Text="Reset" CssClass="btn btn-cart" OnClick="btnReset_Click" />
            &nbsp; Tracks:<asp:Label ID="lblCount" runat="server" Text="Label" EnableViewState="false"></asp:Label>
        </ContentTemplate>
        </asp:UpdatePanel>
    </td>
        
        
    <td valign="bottom" align="right" style="vertical-align:bottom; text-align:right">    
        <asp:Button ID="btnSave" runat="server" Text="PROCESS TRACKS" CssClass="btn btn-orange" OnClick="btnSave_Click" OnClientClick="(document.getElementById(upPurg).style.visibility='hidden');" />
    </td>
    
    <td width="500px;" align="right">
        <!-- FLASH PLAYER -->
        <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="450" height="80" id="player">
	    <param name="allowScriptAccess" value="always" />
	    <param name="allowFullScreen" value="false" />
	    <param name="movie" value="../Flash/player.swf" />
	    <param name="quality" value="high" /><param name="bgcolor" value="#dbdbdb" />
	    <embed swliveconnect="true" src="../Flash/player.swf" quality="high" bgcolor="#dbdbdb" width="450" height="80" name="player" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />
	    </object>
    </td>

    </tr>
    </table>

<div style="position: relative; width: 100%; overflow: scroll; height: 330px;">    
    
    <asp:GridView ID="gvTracks" runat="server" AutoGenerateColumns="False" ShowFooter="true" EmptyDataText="No Tracks to Process at this Time"  
            CellPadding="4" ForeColor="#333333" GridLines="None" Width="100%" Font-Size="X-Small">
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <Columns>
            <asp:TemplateField HeaderText="Play">
                <ItemTemplate>
                    &nbsp;<img id="imgPlay<%# DataBinder.Eval(Container.DataItem, "Filename") %>" src="../images/musicsearch/play.png" alt="Play" onmousedown="javascript:changeImage('<%# DataBinder.Eval(Container.DataItem, "Filename").ToString().Replace(".wav",".mp3").Replace("'","987654") %>','', '<%# DataBinder.Eval(Container.DataItem, "Filename").ToString().Replace(".wav",".mp3").Replace("'","987654") %>');" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Filename" HeaderText="Filename" ItemStyle-Width="150" />
            <asp:BoundField DataField="Username" HeaderText="Username" />
            <asp:BoundField DataField="status" HeaderText="Status" />
            <asp:TemplateField HeaderText="Notes" ItemStyle-Width="222">
                <ItemTemplate><cc2:OboutTextBox ID="tbNotes" runat="server" Text="" TextMode="multiline" Height="50" Width="220"></cc2:OboutTextBox></ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Action" ItemStyle-Width="250">
                <ItemTemplate>
                    Approve<asp:CheckBox ID="chkApprove" runat="server" />
                    Revise<asp:CheckBox ID="chkRevise" runat="server" />
                    Deny<asp:CheckBox ID="chkDeny" runat="server" />
                    Stem<asp:CheckBox ID="chkStem" runat="server" />                    
                </ItemTemplate>
            </asp:TemplateField>

            <asp:TemplateField HeaderText="Reality Genre" ItemStyle-Width="250">
                <ItemTemplate>
                  <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                  <ContentTemplate>                 

                    <cc2:OboutDropDownList ID="ddGenre" runat="server" Width="100"
                         DataSourceID="dsGenres" DataValueField="genre" AutoPostBack="true"
                         DataTextField="genre" AppendDataBoundItems="true">
                          <asp:ListItem Text="...Genre" Value="All" Selected="True"></asp:ListItem>
                    </cc2:OboutDropDownList>

                    <cc2:OboutDropDownList ID="ddSubGenre" runat="server" Width="120"
                         DataSourceID="dsSubGenres" DataValueField="subgenre" DataTextField="subgenre">                                                   
                    </cc2:OboutDropDownList>

                    <!-- Data Sources - Genre / Sub Genre -->
                    <asp:SqlDataSource ID="dsGenres" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:SmashHausConnectionString %>" 
                        SelectCommand="SELECT DISTINCT [genre] FROM [RealityGenres]"></asp:SqlDataSource>        
                
                    <asp:SqlDataSource ID="dsSubGenres" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:SmashHausConnectionString %>" 
                        SelectCommand="SELECT subgenre FROM RealityGenres WHERE genre = @genre ORDER BY subgenre">
                        <SelectParameters>                        
                            <asp:ControlParameter ControlID="ddGenre" DefaultValue="TV" Name="genre" PropertyName="Text" Type="String" />
                        </SelectParameters>	    
                    </asp:SqlDataSource>        

                  </ContentTemplate>
                
                <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ddGenre" EventName="SelectedIndexChanged" />
                </Triggers>
                </asp:UpdatePanel>

                </ItemTemplate>
            </asp:TemplateField>            
            
            <asp:TemplateField HeaderText="Submit to Job">
                <ItemTemplate>
                    <cc2:OboutDropDownList ID="ddJobs" DataSourceID="dsJobs" DataTextField="JobName" runat="server" Width="150" AutoPostBack="false" AppendDataBoundItems="true">
                          <asp:ListItem Text="...Select Job" Value="All" Selected="True"></asp:ListItem>
                    </cc2:OboutDropDownList>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
       
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#263849" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#999999" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView>
    

        <br /><br />
    </div> <!-- Close portlet x12-->
</div> <!-- Close xfluid-->


    <!-- DataSources -->
    <asp:SqlDataSource ID="dsJobs" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SmashHausConnectionString %>" 
        SelectCommand="SELECT [JobName] FROM [Jobs_LookUp]"></asp:SqlDataSource>        
        

</asp:Content>

Open in new window

0
 
LVL 14

Assisted Solution

by:dejaanbu
dejaanbu earned 332 total points
ID: 35170229
Try to put your hole grid inside updatepanel.. Because the grid has to rebind after changing any content know?.. i think so..

also u have 2 update panels. the first one has only 2 buttons and textbox.  if u really want to refresh ur content of textbox/label once one of the button is clicked then have the first one. also if it is needed to  update always, then let it be as it is. if not, make that also to be conditional and choose triggers.

Hope that helps...Good luck!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

764 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