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

[Solved] Binding MVC Grid to a Dataset

1 Answer 172 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Barbaros
Top achievements
Rank 1
Barbaros asked on 08 Feb 2010, 12:03 PM
Dear Folks,

My problem is when using the grid with Entity Framework or such, it is easy to bind the columns and add them,
like in the examples.
   columns.Add(o => o.OrderID).Width(100);
   columns.Add(o => o.Customer.ContactName).Width(200);
   columns.Add(o => o.ShipAddress);
   columns.Add(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120);

But when i use an untyped dataset, 

                    DataTable orders= ds1.Tables[0];                   

                    EnumerableRowCollection<DataRow> query =
                        from order in orders.AsEnumerable()
                        select order;

                    var qorders= query.ToList();

and return this as a model,
columns.Add(o => o["OrderID"];
because the list items are only DataRows and, columns can not be referenced as a public property of a class,
Filtering,Sorting and such does not work.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 08 Feb 2010, 02:25 PM
Hi Barbaros,

Indeed the grid currently requires a c# expression when specifying a bound column. As a workaround I may suggest using ViewModel objects as highlighted in this blog post.

Regards,
Atanas Korchev
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Grid
Asked by
Barbaros
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or