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?
The supported data source type is IQueryable. You can convert your data easily to a List / IQueryable, using extension methods. Example:
dataTable.AsEnumerable().AsQueryable().
Hope it helps,
I have already convert it to IQueryable, but it also throw the exception. Does it not support DataTable?
Do you have the example to bind data with DataTable in Server Side? Because the data from back end are dynamic, so we only can use DataTable with data bind.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Reflection.AmbiguousMatchException: Ambiguous match found.Source Error:
Line 16: </table>*@ Line 17: <!--#BEGIN SNIPPET#--> Line 18: @(Html.Infragistics().Grid(Model).ID("DetailsTable").DataSource(Model).DataBind().Render()) Line 19: <!--#END SNIPPET#--> Line 20: </div>
I am getting the same problem (AmbiguousMatchException).
Has it being fixed/answered?
Looks like its not being able to bind to a DataRow object.
Hello ragnarol ,
Thank you for posting in our forums.
In the below thread is explained how to achieve this using Angel's suggestions:
http://community.infragistics.com/forums/p/64090/324867.aspx#324867
Let us know if you need further assistance.