hi there!

i am using a radgridview(a datagrid in telerik). can you give me a code that sorts the contents of the datagrid? there is an ascending/descending button wherein users can choose how they want the data to be sorted. there is also a combobox that contains the column names that they want the data to be sorted according to that column.

help me please...

6 Years
Discussion Span
Last Post by Saikalyankumar

You, can't sort the values in a datagrid from outer side, but using the columns click of grid on individual columns you can do this go through the following coding.

try {
	if (SortType == false) {
		SortView.Sort = e.SortExpression + " ASC";
		//dviewGeneral.Sort = e.SortExpression & " ASC"
		Session.Item("SortOrder") = SortView.Sort.ToString;
		SortType = true;
	} else {
		SortView.Sort = e.SortExpression + " DESC";
		Session.Item("SortOrder") = SortView.Sort.ToString;
		//dviewGeneral.Sort = e.SortExpression & " DESC"
		SortType = false;
	CMSgrid.SelectedIndex = -1;
	CMSgrid.CurrentPageIndex = 0;
} catch (Exception ex) {

Edited by Saikalyankumar: Modified the code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.