This is a migrated thread and some comments may be shown as answers.

Sorting a grid template column

5 Answers 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Acadia
Top achievements
Rank 1
Acadia asked on 23 Jun 2009, 03:08 PM
Hello,

I have a gridtemplate column that is a label, but the value is a decimal value and I need the column to sort it like a number and not text (it sorts it as text).  I have read numerous posts and the online help but I don't understand exactly what I need to do in order to sort a gridtemplate column in this manner.  I can sort the bound number columns just fine.  Here is my grid column:

 

 

 

<telerik:GridTemplateColumn DataField="TRANS_AMOUNT" HeaderText="Amount" UniqueName="TRANS_AMOUNT"

 

 

 

 

 

AllowFiltering="false" SortExpression="TRANS_AMOUNT" DataType="System.Decimal">

 

 

 

 

 

<HeaderStyle HorizontalAlign="Left" Width="65px" Wrap="False" Font-Size="Smaller" />

 

 

 

 

 

<ItemStyle HorizontalAlign="Right" Width="65px" Wrap="False" />

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

<asp:Label runat="server" ID="lblTransAmount" CssClass="NormalNarrow" Text='<%#DataBinder.Eval(Container, "DataItem.TRANS_AMOUNT") %>'></asp:Label>

 

 

 

 

 

</ItemTemplate>

 

 

 

 

 

</telerik:GridTemplateColumn>

 

 

5 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 23 Jun 2009, 03:44 PM
Hi Acadia,

I am sending you a simple runnable application that demonstrates the needed approach. Please give it a try and let me know if it works for you or if I am leaving something out.

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Acadia
Top achievements
Rank 1
answered on 23 Jun 2009, 06:03 PM
Hi Pavlina,

Thanks for the reply.  Is there any way you could please post this in vb.net?

Thanks
0
Princy
Top achievements
Rank 1
answered on 24 Jun 2009, 05:25 AM
Hello Acadia,

You can make use of the following conversion tool to convert codes from C# to VB or vice versa:
Telerik Code Converter

-Princy.
0
Acadia
Top achievements
Rank 1
answered on 24 Jun 2009, 02:25 PM
I can't seem to get this to work.  I converted the code and plugged it in but I get compile errors on the properties (saying they don't return a value in all code paths).  Is this the only way to make a gridtemplatecolumn sort properly?
0
Pavlina
Telerik team
answered on 25 Jun 2009, 02:21 PM
Hello Acadia,

Please find attached a converted project in VB.NET which is working as expected.
Give it a try and let me know if you have other questions or problems.

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Acadia
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Acadia
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Share this question
or