Click here to Skip to main content
16,004,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if i check checkbox in gridview after that if i click on approve button that particular row should insert in Approve_tbl. if i check 2 rows or 3 or all that rows only should insert in database.
Posted
Updated 27-Sep-11 2:53am
v2

in the button click event you have to check for it like this

C#
protected void INSERTINTODBUSINGCHECKBOX()
{
     for (int i = 0; i < gridview1.Rows.Count; i++)
     {
         if (((CheckBox)gridview1.Rows[i].FindControl("YOUR CHECKBOX ID")).Checked == true)
         {
               //WRITE YOUR CODE FOR INSERT THAT ROW TO DATABASE
         }
     }
}
 
Share this answer
 
You can even call a javascript function on check changed of the chekboxes and store the usefull values in the hiddenfield and then on button click get the values from the hiddenfields otherwise you can also do what tejas has told in the above solution.
 
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