954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to sort datagrid

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...

loraine96
Newbie Poster
8 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

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;
	SortBind();
} catch (Exception ex) {
	MessgeBox.show(ex.ToString());
}
Saikalyankumar
Junior Poster in Training
91 posts since Mar 2011
Reputation Points: 8
Solved Threads: 23
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: