Hi!
I've a radgrid with autogeneratecolumn=true, i'm using advenced databinding to bind the data.
when i change the page or apply filter/sorting the radgrid throws exception during the binding (eg column not found).
the problem occures when change the datasource and reloaded the page.
I tried to set enableviewstatecolumn=false but not works.
Can I help me?
3 Answers, 1 is accepted
I am afraid it is not possible to replicate the issue on our side just by the provided information so far. Please find the attached sample RadGrid Web Site implemented with Advanced DataBinding and let me know whether I am missing something out.
It would be best if you open a support ticket and send us a runnable sample application demonstrating the problematic behavior. Thus, we will be able to further analyze the project and provide a proper solution.
Greetings,
Eyup
the Telerik team

Thanks for the reply.
In your example the select clause is always the same, in my case I change select clause too.
For example the first select contains 3 columns (id, description, value), and the second select contains 2 column (id, description).
1. using the first select ordering by "value column" clicking to the column.
2. change the datasource via button postback doing rebind
3. during rebind radgrid throws exception. (column value not found).
I think the solution is clear the filtering,ordering,sorting and grouping expression. Is the correct way?
There is another way to solve the problem?
You will not face this issue if you have sorted a given column with a datafield also contained in the new datasource. But since you are sorting the initial grid with a datafield which the new datasourse does not contain, this error arises as expected.
One possible approach would be to clear the sorting expressions as you have pointed out. You could achieve that as shown below:
protected
void
Button1_Click(
object
sender, EventArgs e)
{
RadGrid1.MasterTableView.SortExpressions.Clear();
RadGrid1.MasterTableView.FilterExpression =
""
;
RadGrid1.MasterTableView.GroupByExpressions.Clear();
//bind the grid to the new datasource here and finally rebind it
RadGrid1.Rebind();
}
An alternative approach would be to set the visibility of the unwanted columns to false:
protected
void
Button1_Click(
object
sender, EventArgs e)
{
foreach
(GridColumn col
in
RadGrid1.MasterTableView.AutoGeneratedColumns)
{
if
(col.UniqueName ==
"ShipName"
|| col.UniqueName ==
"ShipCountry"
)
{
col.Visible =
false
;
}
}
}
That way you will be able to preserve the sorted state of the grid. Please give it a try and if the problem remains, please send us the mark-up along with the related code behind using the "Format Code Blog".
Regards,
Eyup
the Telerik team