Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
Iam saving that checkbox value(like yes/no)in database.I want to append that value in gridview.If that checkbox value is yes in that database i want to show that checkbox is checked other wise unchecked.


Thanks& Regards
Hari
Posted

Save the Checkbox value in the database as Boolean or YES/NO
the checkbox should pick it up once you bind it
 
Share this answer
 
Comments
Hari Krishna Prasad Inakoti 9-Jan-13 7:46am    
@Joe_i
i saved that checkbox values like yes/no only.I want to show if value is yes in that time checkboxes are checked.how to bind that values to girdview
joe_j 9-Jan-13 9:10am    
I believe that you are using an Item template to show the checkbox in the GridView. if that is so, then in the Template Edit mode you should be getting a Bind option
you should be getting something like this in the aspx code. the one below is for a DDL, you can modify it for a checkbox

<asp:TemplateField HeaderText="Status" SortExpression="status">
<edititemtemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="AccessDataSource2"
DataTextField="status" DataValueField="status" SelectedValue='<%# Bind("status") %>'>


<itemtemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("status") %>'>


here Status is the field that is pulled from the database.
To check the checkbox checkbox1:
checkbox1.checked = true
To uncheck the checkbox checkbox1:
checkbox1.checked = false
 
Share this answer
 
Comments
Hari Krishna Prasad Inakoti 9-Jan-13 7:16am    
I want to check that value from database.
Any way thank you for your comment.
_Vitor Garcia_ 9-Jan-13 7:43am    
either you bind it as joe_j said or you get the value from db and test
if recordset.field.item.value = "Yes" then
checkbox1.checked = true
else
checkbox1.checked = false
I got the solution
Iam saving that checkbox value nw.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900