Hello Friend's,
step 1: I trying textbox data 1st insert in grid. it's clear
but
step 2 : Grid data not insert in data base. it's code here

  protected void btnsavedata_Click(object sender, EventArgs e)
    {


        foreach (GridViewRow g1 in gvloan.Rows)
        {
            SqlConnection con = new SqlConnection(conString);
            SqlCommand com = new SqlCommand("insert into dbo.Test_db(Pf,loan) values ('" + g1.Cells[0].Text + "','" + g1.Cells[1].Text + "')", con);
            con.Open();
            com.ExecuteNonQuery();
            con.Close();

        }

    }

Does your code generate some type of error?

Also, its a better idea to use Parameters... for example...

SqlConnection con = new SqlConnection(conString);
SqlCommand com = new SqlCommand("INSERT INTO dbo.Test_db (pf, loan) VALUES (@param1, @param2)", con);
command.Parameters.AddWithValue("@param1", g1.Cells[0].Text);
command.Parameters.AddWithValue("@param2", g1.Cells[1].Text);
con.Open();
com.ExecuteNonQuery();
con.Close();

if you arent seeing an error, is it possible your sql is working but you are simply inserting null or emtpy data into your table?

it's a sloved code

Be a part of the DaniWeb community

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