Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all,

really need help .. ive insert checkbox in my gridview. and tryin to change some data in the database according to the checkbox that being selected. Really need help please...
Posted

At your aspx.cs try below code:

C#
foreach (GridViewRow gridrow in GridView1.Rows)
       {
           CheckBox cb = (CheckBox)gridrow.FindControl("MovieSelector");
           if (cb != null && cb.Checked)
           {
               string obj = gridrow.Cells[2].Text;
               totalId = totalId + ","+ obj;
           }
       }


this was you can work on every row for which check box is checkedand can update database with required details.

gridrow.Cells[] gives you the value of corresponding column in gridview.

Hope this helped !

Regards,
Divya
 
Share this answer
 
v2
If you want to catch CellContentClick of the Grid then you must use CurrentCellDirtyStateChanged event to commit the changes. Please follow the above link if ur facing same problem :).

<a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.currentcelldirtystatechanged.aspx">http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.currentcelldirtystatechanged.aspx
 
Share this answer
 
Ok! forget about google/bing... just go through this and i am sure you will find enough material:
http://www.codeproject.com/info/search.aspx?artkw=checkbox+gridview[^] :thumbsup:
 
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