asp.net - How to get CheckBox working with ItemTemplate -
i need checkbox working gridview, displays whether checkbox read database checked or not.
sarchive - checkbox field - bit field in database.
if dbnull want no tick in checkbox. unfortunately @ moment it's showing either true or false text next checkbox. when edit record has true, check box not checked, though it's true in database.
screenshot: not edited
screenshot: edited mode
code:
<itemtemplate> <asp:checkbox id="label7" runat="server" text='<%# eval("sarchive") %>' > </asp:checkbox> </itemtemplate> <edititemtemplate> <asp:checkbox id="cb1" runat="server" text='<%# eval("sarchive") == dbnull.value ? false : convert.toboolean(eval("sarchive"))%>'> </asp:checkbox> </edititemtemplate>
any please, thanks. tea.
you have set checked
property:
<asp:checkbox id="label7" runat="server" checked='<%# eval("sarchive") == dbnull.value ? false : convert.toboolean(eval("sarchive")) %>' >
Comments
Post a Comment