Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
for (int intCount = 0; intCount < gvCustomer.Rows.Count; intCount++)
                    {
                        bool chkischeck=false;
                        string strcheck = "";
                   

                     
  ch1 = (DataGridViewCheckBoxCell)gvCustomer.Rows[intCount].Cells[1];
                       if (ch1.Selected)
                       
                        {
  intGridID =Convert.ToInt32(gvCustomer.Rows[intCount].Cells[0].Value);
                            m_Id = intGridID;
                            DeleteData();

                        }


                    }



in this code if first row [0] and second row [1] selected then it doesnot show ch1.Selected=true
for first row it show it show true [1] count and not for count [0]
Posted
Comments
Mahesh Bailwal 21-Jun-13 9:47am    
Can you share your GridView design?

1 solution

Quote:
how to check checkbox is selected or not datagrid

Some thing like this:
C#
foreach (GridViewRow row in GridView1.Rows)
    {
        // Use find control to get the check boxes in grid.
        CheckBox checkbox = (CheckBox)row.FindControl("cbRows");
        //Check if the checkbox is checked.
        if (checkbox.Checked)
        {
            // you will come to know here the check box is selected or not.
        }
    }
 
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