Saturday, January 22, 2011

Finding CheckBoxes in gridview


Follow these steps to find the checkboxes in gridview 

StringBuilder str = new StringBuilder();
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            bool ischecked = ((CheckBox)GridView1.Rows[i].FindControl("Chk1")).Checked;
            if (ischecked)
            {
                str.Append(GridView1.Rows[i].Cells[1].Text);
            }
        }
        Response.Write(str.ToString());

No comments:

Post a Comment