Sunday, May 11, 2008

Telerik.WebControls.GridInsertionObject



In attempting to use the edit form of the Telerik Grid Control, there is an error when there are no records in the table when using an ArrayList of Objects. Since no Objects are in the array list, the RadGrid cannot determine the column headings or the fields for editing. A way around this is to create a DataTable with the proper headings for the fields which need to be entered.


ArrayList units = unitsBusinessLogic.GetAll();

if (units.Count == 0)
{
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("Name", System.Type.GetType("System.String"));
dt.Columns.Add(dc);
dc = new DataColumn("AccessCode", System.Type.GetType("System.String"));
dt.Columns.Add(dc);
RadGrid1.DataSource = dt;
}
else
{
RadGrid1.DataSource = units;
}

No comments:

Check This Out!

More Links to Good Information