Column sorting without using the gridview's _doPostBack javascript

1 posts, 0 answers
  1. wink
    wink avatar
    1 posts
    Member since:
    Sep 2009

    Posted 10 Dec 2009 Link to this post

    I have a page that displays several filters grouped in categories which users can select via expand/collapse feature using javascript.  After selecting the filters, users need to click on a Submit button to see results which are then displayed on the same page in a gridview.  The gridview is nested within a panel with visible="true".  The user needs to be able to sort the column headings in the gridview.  However, if gridview's SortExpression is used, and I click on the column heading, the gridview is not visible anymore.  I need to click on the Submit button again in order to see the sorted gridview.  When I do a hard refresh, the gridview is still visible, but when I click on the column heading which runs a _doPostBack javascript, the gridview is not visible.  Is there any way to enable column sorting without using the gridview's _doPostBack javascript?

    The paging feature is not being used.  I've tried to force the page to display the gridview on page_load, but it just doesn't display. The gridview's visible property is set to true by default.

    Any advice and suggestions would be appreciated.  A snippet of my code is pasted below just in case.

    Thanks!

    On front-end:

    <asp:ImageButton ID="btnSubmit" runat="server" src="images/btn_submit.gif" />  
     
    <asp:panel ID="panResults" runat="server" Visible="true">  
        <asp:GridView ID="gvInventory" runat="server" Width="100%" CssClass="padded" AllowSorting="true" AllowPaging="False" DataSourceID="dsSearchInventory" AutoGenerateColumns="false" Visible="true">  
        <Columns>  
            <asp:TemplateField HeaderText="Reference<br>No." ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" SortExpression="RefNum">  
                <ItemTemplate>  
                     <asp:Label ID="lblRefNum" runat="server" Text='<%# Eval("RefNum") %>'></asp:Label>  
                </ItemTemplate>  
            </asp:TemplateField>      
        </Columns>  
    </asp:GridView>  
     
    <asp:SqlDataSource ID="dsSearchInventory" runat="server" ConnectionString="<%$ ConnectionStrings:dbConn %>" ProviderName="<%$ ConnectionStrings:dbConn.ProviderName %>" SelectCommand="">  
    </asp:SqlDataSource>  
     
    </asp:panel> 

    On code-behind:
    Protected Sub Page_Load(ByVal sender As System.ObjectByVal E As System.EventArgs) Handles MyBase.Load  
            If Page.IsPostBack Then 
                panResults.Visible = True 
            End If 
    End Sub 
     
    Sub btnSubmit_Click(ByVal sender As ObjectByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSubmit.Click  
        'Executes dynamic SQL query string  
    End Sub 
Back to Top