Question:
How to have checkbox that is checked or unchecked depending on a field value being in the Database, and then allow the user to click on it and record the new checkbox state in the database record for that row.
Solution:
webform1.aspx
<
asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 9px; POSITION: absolute; TOP: 15px" runat="server" AutoGenerateColumns="False"DataKeyField="Productid">
<Columns>
<asp:TemplateColumn HeaderText="ProductName">
<ItemTemplate>
<asp:CheckBox id=chk runat="server" Text =<%# DataBinder.Eval(Container.DataItem, "ProductName") %> checked='<%# DataBinder.Eval(Container.DataItem, "Discontinued") %>'></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn ButtonType="PushButton" CommandName="Update" Text="Update"></asp:ButtonColumn></Columns>
</asp:datagrid>
webform1.asp.vb
Step 1:Simple Binding with the DataGrid. The Products Table has the Field Discontinued (DataType:bit) Based on the value 0/1 of the Discontinued field uncheck/check the Checkbox.
ambrish yadavPosted Dec 30, 2007, 12:07 AM
how to insert,update,delete recorde in datagride using checks boxes using asp.net with c#.net
dilip kanadeeditedPosted Dec 20, 2007, 5:51 AMEdited Dec 20, 2007, 5:58 AM
how i select record by checkbox in gridview with c# code
kevin kizerPosted Jun 20, 2007, 11:47 AM
how would you handle null values in the database so you would not throw an exception for dbnull?
venuch babueditedPosted May 25, 2007, 3:03 AMEdited Jun 27, 2007, 5:09 AM
Hi, This is venu frim chennai in india. if i want to more exampels of data grid. paging,sorting with exaples.