user190618
user190618

Reputation:

GridView CheckBox

How do I check the checkbox in gridview on the database bit '1' and uncheck on '0' automatically and then submit the checked values into database? please help me.

Upvotes: 0

Views: 893

Answers (3)

user190618
user190618

Reputation:

I tried this and it simply did the job:

<asp:TemplateField HeaderText="Is Active">
     <ItemTemplate>
     <asp:CheckBox ID="Chk" runat="server" Checked='<%# Bind("fieldname") %>' />
     </ItemTemplate>
</asp:TemplateField>

Upvotes: 1

Carl Rippon
Carl Rippon

Reputation: 4673

A templated field may work:

    <asp:TemplateField HeaderText="Serial Number" SortExpression="SERIALNUMBER" >
                <ItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# iif(Bind("FIELD")=0,"False","True") %>' />
                </ItemTemplate>
            </asp:TemplateField>

Upvotes: 0

Chris Ballance
Chris Ballance

Reputation: 34367

This should get you going

http://www.asp.net/Learn/data-access/tutorial-52-vb.aspx

Upvotes: 0

Related Questions