Click here to Skip to main content
15,915,599 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to delete selected checkbox row in gridview
Posted

You need to use .FindControl and a unique value to delete perticular row.
here is rough idea

C#
for each datagridview row
{
   checkbox chk = new checkbox();
   chk = gridviewrow.findcontrol("chkbox");
   if(chk.checked)
   {
      //delete row with unique value  
   }
   chk = null;
}
 
Share this answer
 
try this..

C#
//On Check Changed event..

CheckBox chk = (CheckBox)(sender);
GridViewRow grdrow = (GridViewRow)(chk.Parent.Parent.Parent);
int index = grdrow.RowIndex;

GridView1.Rows.RemoveAt(index);


hope this helps..
 
Share this answer
 
at click event, using foreach first put all unselected records in dataset and bind that dataset to grid after that. if you can't find solution using this then you can tell me your problem in detail.
 
Share this answer
 
Dear DG Kumar,

Apply a for loop on the grid. Find the check box control from the grid like this:-

for(int i=0;i<grdmain.rows.count,i++)>
     {
       CheckBox chkSel=(CheckBox)grdMain.Rows[i].FindControl("chkselect");
       if(chkSel.checked==true)
         grdMain.Rows.RemoveAt(i);
     }


Make this as your answer if it helps you out.

Thanks

Varun Sareen
 
Share this answer
 
 
Share this answer
 
 
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