Results 1 to 4 of 4

Thread: [RESOLVED] GridView's sort function

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2007
    Posts
    37

    Resolved [RESOLVED] GridView's sort function

    Hi, I'm trying to do this:

    I am working on web app project. I'm using visual studio 2005, .net framework 2.0.

    On Business Logic Layer (BLL), I stored the sql query result in UserCollection (UserCollection is a collection of User object which inherits the generic Collection class, User object is a class defined by me). Then passing this UserCollection to Presentation Layer.

    On Presentation Layer, I bind this UserCollection to a GridView. I enabled Sorting on GridView. I defined the SortExpression for the column that I want to sort via GridView's SmartTag.

    My question is, when I run the application, clicking on the GridView's column header, it will not sort the result. Why is it so? How can I make it able to sort?

    Kindly advice in details. Thank you!!!
    Last edited by thatzlim; Oct 29th, 2007 at 10:27 PM.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2006
    Location
    Madrid
    Posts
    325

    Re: GridView's sort function

    Could you post your grid view code, the aspx code. It might help solve your problem

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2007
    Posts
    37

    Re: GridView's sort function

    Quote Originally Posted by Rauland
    Could you post your grid view code, the aspx code. It might help solve your problem
    Code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim bllUser As New UserBLL
            Dim colUser As UserCollection = bllUser.GetUser()
    
            grdUser.DataSource = colUser
            grdUser.DataBind()
    End Sub
    Code:
    <asp:GridView ID="grdUser" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CssClass="cssGridView"  GridLines="None">
    <Columns>
    <asp:BoundField DataField="UserID" HeaderText="UserID" Visible="False" />
    <asp:BoundField DataField="UserName" HeaderText="UserName" />
    <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
    <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
    <asp:BoundField DataField="DisplayName" HeaderText="DisplayName" SortExpression="DisplayName" />
    </Columns>
    </asp:GridView>

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2007
    Posts
    37

    Re: GridView's sort function

    i have found the solution...
    HOW TO: Using sorting / paging on GridView w/o a DataSourceControl DataSource
    http://forums.asp.net/t/956540.aspx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width