Hi
I am struggling to use a checkbox in a template edit form. When I click on the Add New Record button a Specified cast is not valid error is returned. I have implemented the following code that I found on another thread but the error still occurs. I am using an object datasource and binding. Here is the code that I am using.
Markup
C# code
Thank you
Fred
I am struggling to use a checkbox in a template edit form. When I click on the Add New Record button a Specified cast is not valid error is returned. I have implemented the following code that I found on another thread but the error still occurs. I am using an object datasource and binding. Here is the code that I am using.
Markup
<asp:CheckBox ID="chkControlled" runat="server" Checked= '<%# Bind( "controlled") %>'></asp:CheckBox> |
C# code
protected void radGridAssetCategories_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked |
{ |
GridEditCommandColumn editColumn = (GridEditCommandColumn)radGridAssetCategories.MasterTableView.GetColumn("EditCommandColumn"); |
editColumn.Visible = false; |
e.Canceled = true; |
//Prepare an IDictionary with the predefined values |
System.Collections.Specialized.ListDictionary newnewValues = new System.Collections.Specialized.ListDictionary(); |
//set initial checked state for the checkbox on init insert |
newValues["controlled"] = false; |
//Insert the item and rebind |
e.Item.OwnerTableView.InsertItem(newValues); |
} |
else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted) |
{ |
e.Canceled = true; |
} |
else |
{ |
GridEditCommandColumn editColumn = (GridEditCommandColumn)radGridAssetCategories.MasterTableView.GetColumn("EditCommandColumn"); |
if (!editColumn.Visible) |
editColumn.Visible = true; |
} |
} |
Thank you
Fred