RadGrid: problem displaying bool value in formtemplate type edit form insert mode
I was able to update any records in the grid. However when I clicked on Add New Record, I received an error "specified cast is not valid" on the boolean field "IsActive".
see code below for my ASPX page content
The solution is:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
GridEditCommandColumn editColumn = (GridEditCommandColumn)rgQualificationList.MasterTableView.GetColumn("EditCommandColumn");
editColumn.Visible = false;
e.Canceled = true;
//Prepare an IDictionary with the predefined values
System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary();
//set initial checked state for the checkbox on init insert
newValues["IsActive"] = false;
//Insert the item and rebind
e.Item.OwnerTableView.InsertItem(newValues);
}
1 comment:
Thanks saved my day...
Post a Comment