Hello,
I was wondering how you sort a GridTemplateColumn so that when the user clicks on the column name the column gets sorted ascending and descending.
I haven't seen a clear answer on the forums yet so if anyone can shine any light on this or send me a link to a way in which this could be possible then that would be great.
Thanks
I was wondering how you sort a GridTemplateColumn so that when the user clicks on the column name the column gets sorted ascending and descending.
I haven't seen a clear answer on the forums yet so if anyone can shine any light on this or send me a link to a way in which this could be possible then that would be great.
Thanks
5 Answers, 1 is accepted
0

Vivian
Top achievements
Rank 1
answered on 02 Apr 2012, 09:05 AM
I should add that there is a asp:label within the GridTemplateColumn
0

Shinu
Top achievements
Rank 2
answered on 02 Apr 2012, 09:17 AM
Hello Vivian,
You can set SortExpression for sorting TemplateColumns. Here is the sample code.
aspx:
Thanks,
Shinu.
You can set SortExpression for sorting TemplateColumns. Here is the sample code.
aspx:
<
telerik:GridTemplateColumn
UniqueName
=
"TemplateColumn"
HeaderText
=
"ID"
SortExpression
=
"ID"
>
<
ItemTemplate
>
<%# Eval("ID")%>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
Thanks,
Shinu.
0

Sumit
Top achievements
Rank 1
answered on 25 Sep 2012, 06:14 PM
Hi Shinu,
Your solution doesnt work when you have Label inside GridTemplateColumn.
Your solution doesnt work when you have Label inside GridTemplateColumn.
0

Shinu
Top achievements
Rank 2
answered on 26 Sep 2012, 07:41 AM
Hi Sumit,
Unfortunately i couldn't replicate the issue. Sorting works fine at my end. Please check the following code snippet I tried.
ASPX:
Please provide the code if it doesn't help.
Thanks,
Shinu.
Unfortunately i couldn't replicate the issue. Sorting works fine at my end. Please check the following code snippet I tried.
ASPX:
<
telerik:GridTemplateColumn
UniqueName
=
"TemplateColumn"
HeaderText
=
"ID"
SortExpression
=
"ID"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"label1"
runat
=
"server"
Text='<%# Eval("ID")%>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
Please provide the code if it doesn't help.
Thanks,
Shinu.
0

Sumit
Top achievements
Rank 1
answered on 26 Sep 2012, 08:01 AM
Hi Shinu,
Thanx for your quick reply. I created a new project and your solution works.
Thanx for your quick reply. I created a new project and your solution works.