Click here to Skip to main content
14,735,478 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to delete a row from gridview by using a checkbox.

I was facing a problem with the code behind.
How to write the code for the button.
I want it so that if I press this button then the selected checked rows should be deleted.

Help me on this topic.
Posted
Updated 8-Nov-10 23:37pm
v3
Comments
JF2015 9-Nov-10 4:00am
   
Your question is not clear. PS: please when posting try to use correct english - it was very hard to read your question, so please keep it formal!
Dalek Dave 9-Nov-10 4:37am
   
Edited for Readability and Syntax.

foreach(GridViewRow row in gv1.Rows)
        {
//Give your cell index where checkbox resides e.g 0 and if checkbox is only a control in a cell then just give 0 as a index in control otherwise change it accordingly            
if(((CheckBox)row.Cells[0].Controls[0]).Checked)
            {
// Apply your operation here on checked checkbox row.
            }
        }


Please vote and Accept Answer if it Helped.
   
Comments
Dalek Dave 9-Nov-10 4:37am
   
Good 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