CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2007
    Posts
    144

    Sorting Template Columns in a Datagrid

    My data grid is set to allow sorting..

    I have looked up a few ways to do this and am Still a bit unclear.
    What steps need to be taken from here to make the column header a link to make the dataset coming in 'Asc' , 'Desc' Sortable..

    I am using C# in the back

    Code:
    <asp:TemplateColumn SortExpression="Email_Add" HeaderText="Email Address">
    <HeaderTemplate>Email Address</HeaderTemplate>
      <ItemTemplate>
                <asp:Label id=lblEmail_Provided Font-Bold="true" Runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Email_Add") %>'	
                </asp:Label>
        </ItemTemplate>
    </asp:TemplateColumn>

  2. #2
    Join Date
    Aug 2009
    Posts
    12

    Re: Sorting Template Columns in a Datagrid

    To make a link appeared at the column header that allows sorting on the result,

    you have to put SortExpression in your TemplateColumn, like your provided code
    <asp:TemplateColumn SortExpression="Email_Add" HeaderText="Email Address">

    Definite AllowSorting is a must to enabled.

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

Featured