how to get the grid items???
-
hi friends, fine and hope u so.. i am trying to include checkbox in the datagrid... this is my coding CheckBox chkbox = new CheckBox(); TextBox txtbox= new TextBox(); foreach(DataGridItem item in DGSample.items ) { chkbox=(CheckBox)item.FindControl("chkbox"); txtbox=(TextBox)item.FindControl("txtbox"); if(chkbox.Checked) { Response.Write(item.Cells[0].Text); } } in this coding i am getting probs...in the for loop..... initially i got error like this... Error:'System.Web.UI.WebControls.GridView' does not contain a definition for 'items' so ... i tried with foreach(DataGridItem item in DGSample.rows ) even i am getting error like Unable to cast object of type 'System.Web.UI.WebControls.GridViewRow' to type 'System.Web.UI.WebControls.DataGridItem'. can u anyone help me to solve this prob???
-
hi friends, fine and hope u so.. i am trying to include checkbox in the datagrid... this is my coding CheckBox chkbox = new CheckBox(); TextBox txtbox= new TextBox(); foreach(DataGridItem item in DGSample.items ) { chkbox=(CheckBox)item.FindControl("chkbox"); txtbox=(TextBox)item.FindControl("txtbox"); if(chkbox.Checked) { Response.Write(item.Cells[0].Text); } } in this coding i am getting probs...in the for loop..... initially i got error like this... Error:'System.Web.UI.WebControls.GridView' does not contain a definition for 'items' so ... i tried with foreach(DataGridItem item in DGSample.rows ) even i am getting error like Unable to cast object of type 'System.Web.UI.WebControls.GridViewRow' to type 'System.Web.UI.WebControls.DataGridItem'. can u anyone help me to solve this prob???
The
DataGridItem
was used with the older DataGrid control. You need to use the following:foreach (GridViewRow item in DGSample.Rows)
{
}