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

Custom binding with DataTable object problem

0 Answers 62 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.
Jero
Top achievements
Rank 1
Jero asked on 09 May 2012, 01:45 PM
Hi,
I have several methods in my data layer which return strong typed DataTable objects.
I have successfully using the MVC Grid converting my  strong typed DataTable objects to non typed DataTables, now I want to use a custom logic for the pagination so I retrieve from the DB only the rows I need and not all of them but I have realized I can't because the Data object in the GridModel constructor only accept IEnumerable lists and not DataTable objects:

return View(new GridModel
            {
                Data = myData,
                Total = myTotal
            })

If I try to convert my DataTable to  IEnumearble<System.Data.DataRow> or IEnumerable<dynamic> a new error appears when a column in the row has null value, throwing an exception that a conversion from Null to string is not possible, any idea?

Thanks in advance.
Tags
Grid
Asked by
Jero
Top achievements
Rank 1
Share this question
or