Hi All,
I have a RadGrid that you can edit and add a new record in. when I click on Edit, it show the edit form and works fine, and when I click on Add new record it also works fine because I added this code in the commandItem of the grid:
Now if I click on Add new record and without clicking on Insert or Cancle then click on edit for one of the other record, it give me this error: Conversion from type 'DBNull' to type 'Boolean' is not valid.
That is because I have a checkbox in the EditItemTemplate:
Is there a way to fix this by adding a line of code or a way around it by disabling the user to click edit when Add new record button is clicked(inserting a new record)?
Thank you in advance
Shehab
I have a RadGrid that you can edit and add a new record in. when I click on Edit, it show the edit form and works fine, and when I click on Add new record it also works fine because I added this code in the commandItem of the grid:
| Protected Sub rgResidentAdmin_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles rgResidentAdmin.ItemCommand |
| If (e.CommandName = RadGrid.InitInsertCommandName) Then |
| e.Canceled = True |
| Dim newValues As System.Collections.Specialized.ListDictionary = New System.Collections.Specialized.ListDictionary() |
| newValues("ResIndic") = "1" |
| e.Item.OwnerTableView.InsertItem(newValues) |
| End If |
| End Sub |
That is because I have a checkbox in the EditItemTemplate:
| <radG:GridTemplateColumn DataField="ResIndic" HeaderText="Active" UniqueName="ResIndic" AllowFiltering="False"> |
| <ItemTemplate> |
| <asp:CheckBox ID="cbResIndic" runat="server" Enabled="false" /> |
| </ItemTemplate> |
| <EditItemTemplate> |
| <asp:CheckBox ID="ResIndicCB" runat="server" Checked='<%# Bind("ResIndic")%>' /> |
| </EditItemTemplate> |
| </radG:GridTemplateColumn> |
Thank you in advance
Shehab