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

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());
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.