Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello everybody,

I have a GridView and I put checkboxes inside all its cells. I want to do the following:
if the checkbox checked by the user, this means Yes which will be stored in the database
else, if the checkbox unchecked by the user, this means No and no need to post anything to the database.

I know I need now to identify each checked checkbox and know which cell this checked checkbox is underneath it.

Any idea about how to do that? Could anyone give me the basic piece of code for doing this?
Posted

try this
C#
for (int x = 0; x < grdview.Rows.Count; x++)
 {
 CheckBox chkDoc = (CheckBox) grdview.Rows[x].FindControl("chkDoc");

            if (chkDoc.Checked)
            {
                //apply your logic here
            }
        }
 
Share this answer
 
use <asp:TemplateField></asp:TemplateField> then in the <ItemTemplate></ItemTemplate> scope of GridView, put your CheckBox code ...
 
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