Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to save data from two columns of gridview on the clicking of save button.
I used below code.


HTML
string pageid1 = "";
            foreach (GridViewRow grrow1 in Gridheader.Rows)
            {
                CheckBox chk = (CheckBox)grrow1.FindControl("Chk1");
                if (chk.Checked == true)
                {
                    Label id1 = (Label)grrow1.FindControl("lblpageid");
                    pageid1 = id1.Text.ToString();
                    string pageid = "";
                    foreach (GridViewRow grrow in Gridpage.Rows)
                    {
                        CheckBox chk1 = (CheckBox)grrow.FindControl("chk2header");
                        if (chk1.Checked == true)
                        {
                            con.Open();
                            Label id = (Label)grrow.FindControl("lbl2pageid");
                            pageid = pageid1.ToString();
                            cmd = new SqlCommand("Save_Pages", con);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.AddWithValue("@typeid", ddlSelectedtypeid.SelectedValue);
                            cmd.Parameters.AddWithValue("@pageid", pageid);
                            cmd.ExecuteNonQuery();
                            con.Close();
                        }
                    }
                }



But data is not successfully saved.please giv me code
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900