mardi 2 février 2016

Checkbox in EditItemTemplate is always null

I have a checkbox field called "status" in my gridview. It is a bit field in the database. Whether this field is checked or not upon update, the result always gets passsed in as "null" in the database. This is the asp code:

<EditItemTemplate>
   <asp:CheckBox ID="CheckBox1" runat="server" 
      Checked='<%# Eval("status") == DBNull.Value ? false : Convert.ToBoolean(Eval("status")) %>' />
</EditItemTemplate>
<ItemTemplate>
   <asp:CheckBox ID="CheckBox1" runat="server" 
      Checked='<%# Eval("status") == DBNull.Value ? false : Convert.ToBoolean(Eval("status")) %>' Enabled="false" />
</ItemTemplate>

How do I pass in the proper values (0 or 1) on update?




Aucun commentaire:

Enregistrer un commentaire