I use the following code to server bind igGrid, but it can not work.
@(Html.Infragistics().Grid<System.Data.DataRow>().ID("DataTableId").DataSource(Model.AsQueryable()).DataBind().Render())
How to bind the DataSource with DataTable?
Thanks.
hi ,
could you give some more details about exactly what doesn't work ? Do you get an empty grid, do you get an exception, etc? could you also show your controller code. Do you get any errors in the Javascript console of your browser ?
Thanks,
Angel
Thanks your replay.
my controller code as below:
public ActionResult Details()
{
System.Data.DataTable table = GetDataTable();
return View("Details","",table.AsEnumerable());
}
private DataTable GetDataTable()
// Create a new DataTable.
DataTable table = new DataTable("childTable");
DataColumn column;
DataRow row;
// Create first column and add to the DataTable.
column = new DataColumn();
column.DataType = System.Type.GetType("System.Int32");
column.ColumnName = "ChildID";
// Add the column to the DataColumnCollection.
table.Columns.Add(column);
// Create second column.
column.DataType = System.Type.GetType("System.String");
column.ColumnName = "ChildItem";
// Create three sets of DataRow objects,
// five rows each, and add to DataTable.
for (int i = 0; i <= 4; i++)
row = table.NewRow();
row["childID"] = i;
row["ChildItem"] = "Item " + i;
table.Rows.Add(row);
return table;
I have tested 2 cases.
1, If GetDataTable() return 0 record,
It will show the loading image all the time in the page when I open the view page. And there is no grid bound in the page.
2, If GetDataTable() return more than one record.
It will throw an "Ambiguous match found" exception
Your official samples are only Collections(List) or Json data for JavaScript. Do you have any sample
that bind with DataTable with Server side?