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

[Solved] Sorting in grid using GridTemplateColumn

1 Answer 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rajasekar Nammalvar
Top achievements
Rank 1
Rajasekar Nammalvar asked on 06 Nov 2009, 05:35 AM

Hi,

I am using below template in grid :-

 
<telerik:GridTemplateColumn HeaderText="SequenceOrder" Groupable="false" Visible="true">
<ItemTemplate>
<telerik:RadNumericTextBox ID="txtSequence" runat="server" MaxLength="5" NumberFormat-DecimalDigits="0">
</telerik:RadNumericTextBox>
</ItemTemplate>
</telerik:GridTemplateColumn>

This is done to assign a sequence to existing RowItems.

Hence when a user enters some number in above textbox and press a button the sequence is updated in database.
And when the user loads the application this textboxes are populated with previously entered sequence at runtime in ItemDataBound Event as below :-
 
 

RadNumericTextBox txtSequence = e.Item.FindControl("txtSequence") as RadNumericTextBox;
DataTable table = GetSequenceData();
if (table != null)
{
 if (table.Rows.Count == 1)
 {
  txtSequence.Text = table.Rows[0][0].ToString();
 }
}

Is there any way i can sort rows of this grid based on entered sequence values.

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 06 Nov 2009, 03:56 PM
Hi Rajasekar,

To enable sorting for GridTemplateColumn, you need to set appropriate SortExpression values that should match the data field you want to sort on (typically the field a control in the template is bound to).

More information about sorting GridTemplateColumn is available here:
http://www.telerik.com/help/aspnet-ajax/grdsortingforhyperlinktemplatecolumns.html

Regards,

Pavlina
the Telerik team

 


Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Rajasekar Nammalvar
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or