grid view cell value
-
i want to get a value of cell where check box is clicked. and geeting an error of Oject Refence is not set to an instance of an object. plz tell how i can get a value
foreach (GridViewRow row in GridView1.Rows) { bool result = ((CheckBox)row.FindControl("CheckBox1")).Checked; if (result) { //error is Oject Refence is not set to an instance of an object. String id = ((TextBox)row.Cells[0].FindControl("TextBox1")).Text; } }
-
i want to get a value of cell where check box is clicked. and geeting an error of Oject Refence is not set to an instance of an object. plz tell how i can get a value
foreach (GridViewRow row in GridView1.Rows) { bool result = ((CheckBox)row.FindControl("CheckBox1")).Checked; if (result) { //error is Oject Refence is not set to an instance of an object. String id = ((TextBox)row.Cells[0].FindControl("TextBox1")).Text; } }
Please check the RowType before you use FindControl function. I think you are searching the CheckBox in HeaderRow. Use FindControl when the RowType is an Item.
Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group