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

Remove Sorting from Grid in Code Behind

1 Answer 245 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anish
Top achievements
Rank 1
Anish asked on 14 Nov 2011, 06:25 PM
Hi I have a grid with 10 Columns which i bind with different data sources at different times.
based on the Databinding my columns gets visible.
Now when i click on a certain column which my grids get sorted for the first time.

now i again bind the grid by perofrming some page action. the problem is my grid still has previously sorted column and my new datasource does not contain this column. due to this i am getting error.

I need something which will deselect any sorted column when i rebind the datasource.

Example:
Grid has datasource with Name, ID and Age Field.
I sort on Name first.

Now i will bind grid with new Datasource which has only ID and Age.

at this moment i am getting error that your datasource does not have column name "Name" for sorting.

Kindly help me.

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 14 Nov 2011, 07:26 PM
Hello,

try with below code snippet.

RadGrid1.MasterTableView.SortExpressions.Clear();
              
            RadGrid1.Rebind();
            //or
            RadGrid1.DataSource = "Your data source";
            RadGrid1.DataBind();


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Anish
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or