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

Radgrid Not Sorting

3 Answers 175 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 21 Nov 2013, 08:10 PM
Hi All,

I have C# code-behind RadGrid that uses SQLDataSource and Databinds in NeedDataSource();

I have set
radGrid.AllowSorting = true;
radGrid.MasterTableView.AllowMultiColumnSorting = true;
radGrid.MasterTableView.AllowNaturalSort = true;

I have also set AllowSorting= true; on the columns themselves, but nothing seems to work.  The columns refuse to sort, even though I can see the Arrow Up, Arrow Down and revert to default.  Can you please help?

Thanks,
Mark

3 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
answered on 21 Nov 2013, 08:41 PM
A couple more notes:

I set the RadGrid.DataSource = SQLDataSource when I generate the grid, and Ajax is disabled.
0
Mark
Top achievements
Rank 1
answered on 21 Nov 2013, 10:14 PM
Huh, that's interesting . . .

If I set RadGrid.DataSourceID = SQLDataSource.ID the sorting works, but if I set RadGrid.DataSource = SQLDataSource it does not work. 

Why is that?
0
Princy
Top achievements
Rank 2
answered on 22 Nov 2013, 06:00 AM
Hi Mark,

The DataSource- gets or sets objects from which the telerik radgrid control retrieves its list of data items, where as
DataSourceID- gets or sets the ID of the control from which the radgrid control retrieves its list of data items.
Using DataSource you can bind DataTable or Data Sets etc to the RadGrid and using DataSourceID, you can set the ID of the datasource controls like SqlDataSource, AccessDataSource, ObjectDataSource, EntityDataSource, LinqDataSource etc that you use.

C#:
RadGrid1.DataSourceID = "SqlDataSource1";
      //OR
RadGrid1.DataSource = GetDataTable("SELECT * FROM TableName");

Thanks,
Princy

Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or