HI There
I'm working with a Radgrid and I'm having an issue whereby a checkbox in a TemplateColumn's InsertItemTemplate section is not storing it's value in the DB.
The Textbox in another column is working fine, and I can go and edit the Row afterwards and select the checkbox if I wanted to, that works. But, on Insert, the checkbox's checked state is not stored in the DB.
Here are the 2 columns (first one works fine, the other doesn't):
<telerik:GridTemplateColumn Reorderable="true" UniqueName="TemplateColumn" FilterControlAltText="Filter TemplateColumn column" DataField="typeofhardware" SortExpression="typeofhardware"> <HeaderTemplate> <asp:LinkButton Text="Type of HW" ID="HWSortbutton" ToolTip="Click to Sort" CommandName="Sort" CommandArgument="typeofhardware" runat="server" /> </HeaderTemplate> <ItemTemplate> <asp:Label Text='<%# Bind("typeofhardware") %>' ID="lblTypeofHW" runat="server" /> </ItemTemplate> <EditItemTemplate> <table style="width: 100%"> <tr> <td> <asp:Label Text="Type of Hardware" runat="server" /> </td> <td style="width: 25px;"></td> <td> <asp:TextBox runat="server" ID="txtTypeOfHardware" Width="100%" Text='<%# Bind("typeofhardware") %>' /> </td> </tr> </table> </EditItemTemplate> <InsertItemTemplate> Type of Hardware: <asp:TextBox runat="server" Text='<%# Bind("typeofhardware") %>' ID="txtTypeOfHardware" /> </InsertItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn Reorderable="true" DataType="System.Boolean" UniqueName="HidemeColumn" FilterCheckListEnableLoadOnDemand="false" DataField="hideme" SortExpression="hideme"> <HeaderTemplate> <asp:LinkButton Text="Hidden?" ID="HiddenSortbutton" ToolTip="Click to Sort" CommandName="Sort" CommandArgument="hideme" runat="server" /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox Checked='<%# Bind("hideme") %>' Enabled="false" ID="chkHidden" runat="server" /> </ItemTemplate> <EditItemTemplate> Hidden?: <asp:CheckBox ID="chkHidden" runat="server" /> </EditItemTemplate> <InsertItemTemplate> Hidden?: <asp:CheckBox ID="chkHidden" runat="server" /> </InsertItemTemplate> </telerik:GridTemplateColumn>I've tried many things to solve this, firstly tried Binding the checked property of the checkbox in the InsertItemTemplate like this:
<asp:CheckBox Checked='<%# Bind("hideme") %>' ID="chkHidden" runat="server" />That produces a cast error though.
Doing this doesn't cause any error:
<asp:CheckBox Checked='<%# DataBinder.Eval(Container.DataItem, "hideme") is DBNull ? false : Eval("hideme") %>' ID="chkHidden" runat="server" />The problem is however that when I submit the Insert Form, the value of the checkbox is not stored in the DB.
Any ideas?
Regards
JohannS