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

enter image description here

screenshot: edited mode

enter image description here

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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -