I am designing a project in asp.net. I one page i have created a gridview having template field as checkbox. When I select any row in gridview using checkbox,that checked row goes to a new gridview on button click. Now what i want to do is to save that new gridviewin sql. How to save that gridview ????
Pls help.

protected void Button1_Click1(object sender, EventArgs e)
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            DataColumn dc = new DataColumn("id", typeof(int));
            DataColumn dc1 = new DataColumn("name", typeof(string));
            DataColumn dc2 = new DataColumn("designation", typeof(string));
            DataColumn dc3 = new DataColumn("group_name", typeof(string));
            foreach (GridViewRow grow in GridView1.Rows)
                CheckBox cbox = (CheckBox)grow.FindControl("cbox");
                if (cbox.Checked == true)
                    DataRow dr = dt.NewRow();
                    dr["id"] = grow.Cells[1].Text;
                    dr["name"] = grow.Cells[2].Text;
                    dr["designation"] = grow.Cells[3].Text;
                    dr["group_name"] = grow.Cells[4].Text;

            GridView2.DataSource = ds;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.