How to sort template field by clickin gridview column header

Posted by Oswaldlily under ASP.NET on 7/29/2011 | Points: 10 | Views : 34240 | Status : [Member] | Replies : 1
hey this is my column in my gridview ..i need to use sorting.
condition 1) i dont want to write sql query in codebehind.
i can write in storedprocedure and call in codebehind

then i need to know whether v can sort without any query....
since i dint use boundfield feelin lot of confusion in sorting.
so plz help me

<asp:TemplateField HeaderText="Employeename" SortExpression="Employeename" >
<asp:LinkButton ID="lnkgroup" runat="server" CommandArgument="Employeename" CommandName="Sort"
ForeColor="white" Text="<%$ Resources:DefaultResource, Employeename %>"
<asp:Label ID="lab2" runat="server"
Text='<%# Eval("Employeename") %>' Width="300px"></asp:Label>
<asp:TextBox ID="TxtId" runat="server"


Posted by: SheoNarayan on: 7/29/2011 [Administrator] HonoraryPlatinum | Points: 25

Hi Vijila,

Its not as hard as it looks like, read this article, in this for every sorting a new database query is not executing. Sorting is being done at the page level using the DataView.


Sheo Narayan

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response