Retrieving the check box rows from gridview
-
i am trying to add checkbox column to gridview and pick the rows which were selected , while doing this i am not able to get the rows selected, could some one say what could be the problem in the code the code i am working on is added a new check box column to gridview as ; ; ; to retrieve the rows selected i am using the code CheckBox cbCelda = new CheckBox(); int i = 0; while (i < grdViewpapers.Rows.Count) { cbCelda = (CheckBox)grdViewpapers.Rows[i].FindControl("chkassignpaper"); if (cbCelda.Checked) { Response.Write("hi" + i); } i++; } can some one say what could be the problem in accessing rows.....
Thanks srini
-
i am trying to add checkbox column to gridview and pick the rows which were selected , while doing this i am not able to get the rows selected, could some one say what could be the problem in the code the code i am working on is added a new check box column to gridview as ; ; ; to retrieve the rows selected i am using the code CheckBox cbCelda = new CheckBox(); int i = 0; while (i < grdViewpapers.Rows.Count) { cbCelda = (CheckBox)grdViewpapers.Rows[i].FindControl("chkassignpaper"); if (cbCelda.Checked) { Response.Write("hi" + i); } i++; } can some one say what could be the problem in accessing rows.....
Thanks srini
What error messages are you getting? Have you stepped through your code? Have you populated the gridview with data?
-
i am trying to add checkbox column to gridview and pick the rows which were selected , while doing this i am not able to get the rows selected, could some one say what could be the problem in the code the code i am working on is added a new check box column to gridview as ; ; ; to retrieve the rows selected i am using the code CheckBox cbCelda = new CheckBox(); int i = 0; while (i < grdViewpapers.Rows.Count) { cbCelda = (CheckBox)grdViewpapers.Rows[i].FindControl("chkassignpaper"); if (cbCelda.Checked) { Response.Write("hi" + i); } i++; } can some one say what could be the problem in accessing rows.....
Thanks srini
-
May be change your code like this int i = 0; while (i < grdViewpapers.Rows.Count) { CheckBox cbCelda = (CheckBox)grdViewpapers.Rows[i].FindControl("chkassignpaper"); if(cbCelda != null) { if (cbCelda.Checked) { Response.Write("hi" + i); } } i++; }
Hi, Thanks for the quick response, i got the problem solved.
Thanks Mukkanti
-
i am trying to add checkbox column to gridview and pick the rows which were selected , while doing this i am not able to get the rows selected, could some one say what could be the problem in the code the code i am working on is added a new check box column to gridview as ; ; ; to retrieve the rows selected i am using the code CheckBox cbCelda = new CheckBox(); int i = 0; while (i < grdViewpapers.Rows.Count) { cbCelda = (CheckBox)grdViewpapers.Rows[i].FindControl("chkassignpaper"); if (cbCelda.Checked) { Response.Write("hi" + i); } i++; } can some one say what could be the problem in accessing rows.....
Thanks srini
use this link and see download the sample program... GridView all in one[^]
Padmanabhan