Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1572
  • Last Modified:

Update Panel not refreshing

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
JT_SIRO
Asked:
JT_SIRO
  • 2
  • 2
3 Solutions
 
Rajkumar GsSoftware EngineerCommented:
Try UpdateMode="Conditional">
<asp:UpdatePanel id="UpdatePanel1" runat="server" UpdateMode="Conditional"> 

Open in new window


Raj
0
 
Rajkumar GsSoftware EngineerCommented:
0
 
dejaanbuCommented:
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
 
JT_SIROAuthor Commented:
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
 
dejaanbuCommented:
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
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.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now