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>
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.