This is a migrated thread and some comments may be shown as answers.

Column sorting without using the gridview's _doPostBack javascript

0 Answers 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
wink
Top achievements
Rank 1
wink asked on 10 Dec 2009, 10:16 PM

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 
Tags
General Discussions
Asked by
wink
Top achievements
Rank 1
Share this question
or