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

AllowAddNewRow when bound to LINQ datasource

1 Answer 112 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tor Sigve Taksdal
Top achievements
Rank 1
Tor Sigve Taksdal asked on 22 Jul 2010, 09:22 PM
private Unit u = new Unit();
u.setUnitContext();
IObjectScope context = u.context;
var q =  from d in context.Extent<TblUnitType>()
select new { d.UnitType, d.Abbreviation };
radGridView1.DataSource = q.ToList();

When setting the grid.MasterTemplate.AllowAddNewRow = true; and upong adding a new row to the grid it throws an ArgumentOutOfRangeException...  If a bind to a datatable everything works fine...

The question is how do I add a new row to the rows collection when the grid is bound to a "linq query".

Regards
Tor Sigve

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 28 Jul 2010, 11:57 AM
Hello Tor Sigve Taksdal,

Thank you for your question.

The AddNew logic depends on the IList or IBindingList implementation bound to RadGridView. In your scenario the ToList() method of your query returns a read-only list which does not support adding new items to it. Please verify the IList implementation, returned from q.ToList() and if needed insert additional layer to your logic that converts all the data to a collection which implements IList and IBindingList interfaces like the DataTable class - it has support for all the CRUD operations.

I hope this information is useful.

Regards,
Julian Benkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Tor Sigve Taksdal
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or