I have a RadGrid setup so that double clicking a row opens a form under the row to allow editing. The form itself lives in a web user control.
On this form one of the fields is a CheckBox. It looks like this.
The code in the 'Checked=' bit sees that on edit the Checked property gets set to True or False. Perfect.
However, when I hit the Add New Record button, this line gets a problem.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Source File: c:\Dev\RadGrid\RadGrid\Controls\ContactDetails.ascx Line: 26
It's pretty easy to understand why. DataItem.con_Is_Active has no value on an Add New Record insert.
My question is, were do I intercept this to prevent this error on Adding a new Record?
I've looked for but have been unable to find the InitInsertButtons click event if any such event exists..
I'm sure this is simple I just don't know where to put such a check. I suppose what I'd like to do is set the DataItem.con_Is_Active property some default value (like 'False') before the it gets to this point.
On this form one of the fields is a CheckBox. It looks like this.
<
td
><
asp:CheckBox
ID
=
"chkIsActive"
runat
=
"server"
Checked='<%# DataBinder.Eval( Container, "DataItem.con_Is_Active") %>' /></
td
>
The code in the 'Checked=' bit sees that on edit the Checked property gets set to True or False. Perfect.
However, when I hit the Add New Record button, this line gets a problem.
Specified cast is not valid.
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.InvalidCastException: Specified cast is not valid.
Source Error:
Line 24: <tr>
Line 25: <td align="right">Active:</td>
Line 26: <td><asp:CheckBox ID="chkIsActive" runat="server" Checked='<%# DataBinder.Eval( Container, "DataItem.con_Is_Active") %>' /></td>
Line 27: <td></td>
Line 28: <td></td>
|
Source File: c:\Dev\RadGrid\RadGrid\Controls\ContactDetails.ascx Line: 26
It's pretty easy to understand why. DataItem.con_Is_Active has no value on an Add New Record insert.
My question is, were do I intercept this to prevent this error on Adding a new Record?
I've looked for but have been unable to find the InitInsertButtons click event if any such event exists..
I'm sure this is simple I just don't know where to put such a check. I suppose what I'd like to do is set the DataItem.con_Is_Active property some default value (like 'False') before the it gets to this point.