I have a gridview controller with a set of BoundField columns to my data source. I also have a CheckBoxField that I want checked depending on if that row in the table I get from the database is marked accordingly. The problem is, Oracle does not have a boolean type and ASP.NET is expecting a boolean to mark the check box. Is there some sort of work around for this?
Here is my gridview with the check box column.
<asp:GridView ID="DeviceGridView" runat="server" CssClass="SmallGridView"
DataSourceID="DeviceDataSource" AutoGenerateColumns="False"
EmptyDataText="No devices found." CellPadding="4" ForeColor="#333333"
GridLines="None" OnRowCreated="GridView_RowCreated"
OnRowDataBound="GridView_RowDataBound" >
<FooterStyle CssClass="gridViewFooter" />
<RowStyle CssClass="gridViewRow" />
<EditRowStyle CssClass="gridViewEditRow" />
<SelectedRowStyle CssClass="gridViewSelectedRow" />
<HeaderStyle CssClass="gridViewHeader" />
<AlternatingRowStyle CssClass="gridViewAltRow" />
<Columns>
<asp:BoundField HeaderText="DeviceID" DataField="device_id" />
<asp:BoundField HeaderText="Device Type" DataField="device_type" />
<asp:BoundField HeaderText="Description" DataField="description" />
<asp:BoundField HeaderText="Enable Logging" DataField="enable_logging" />
<asp:CheckBoxField DataField="normal_toggle" Text="Normal User Logging" />
</Columns>
</asp:GridView>
Instead of using
<asp:CheckBoxField>, try using a template field:That will make your checkbox checked if
normal_togglevalue equals 1 and unchecked otherwise. Adjust to your data accordingly.Update
Added an event to the
<asp:Checkbox>inside the template field.