add check box to gridview and get the checked rows in gridview to another gridview in c#.net
-
AutoGenerateColumns="false" Font-Bold="true" ForeColor="#003300" OnRowDataBound="gridview1_RowDataBound" Width="186px" OnSelectedIndexChanged="gridview1_SelectedIndexChanged" OnRowCreated="gridview1_RowCreated"> ; InsertVisible="False" ReadOnly="True" SortExpression="Name" > SortExpression="ID" > code behind for getting selected checkbox herere iam not able to get the checked rows.plz find an solution protected void Button1_Click(object sender, EventArgs e) { foreach (GridViewRow row in gridview1.Rows) { DataTable dt=new DataTable(); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("ID", typeof(string))); CheckBox Check = (CheckBox)row.Cells[3].FindControl("chk1"); if (Check.Checked) { dt.Rows.Add(); dt.Rows.Add(row); } } } find a solution to get the checked rows in gridview with regards n.priya
priya
-
AutoGenerateColumns="false" Font-Bold="true" ForeColor="#003300" OnRowDataBound="gridview1_RowDataBound" Width="186px" OnSelectedIndexChanged="gridview1_SelectedIndexChanged" OnRowCreated="gridview1_RowCreated"> ; InsertVisible="False" ReadOnly="True" SortExpression="Name" > SortExpression="ID" > code behind for getting selected checkbox herere iam not able to get the checked rows.plz find an solution protected void Button1_Click(object sender, EventArgs e) { foreach (GridViewRow row in gridview1.Rows) { DataTable dt=new DataTable(); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("ID", typeof(string))); CheckBox Check = (CheckBox)row.Cells[3].FindControl("chk1"); if (Check.Checked) { dt.Rows.Add(); dt.Rows.Add(row); } } } find a solution to get the checked rows in gridview with regards n.priya
priya
try this, string checkedrows=""+request.Form["CheckboxId"]; if ur checkbox is inside a gridview and it is a Inputype.
-
AutoGenerateColumns="false" Font-Bold="true" ForeColor="#003300" OnRowDataBound="gridview1_RowDataBound" Width="186px" OnSelectedIndexChanged="gridview1_SelectedIndexChanged" OnRowCreated="gridview1_RowCreated"> ; InsertVisible="False" ReadOnly="True" SortExpression="Name" > SortExpression="ID" > code behind for getting selected checkbox herere iam not able to get the checked rows.plz find an solution protected void Button1_Click(object sender, EventArgs e) { foreach (GridViewRow row in gridview1.Rows) { DataTable dt=new DataTable(); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("ID", typeof(string))); CheckBox Check = (CheckBox)row.Cells[3].FindControl("chk1"); if (Check.Checked) { dt.Rows.Add(); dt.Rows.Add(row); } } } find a solution to get the checked rows in gridview with regards n.priya
priya
Use
GridViewRow
, set the selected rows to that new gridview row, now you can use it any other gridview on that page. For any other page use Session . :)Best Regards ----------------- Abhijit Jana Check Out My Latest Article Java.NET : Integration of Java and .NET[^] "Success is Journey it's not a destination"