Hi
I want when i enter data in datagridview cell then that store or insert in database table
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pravin GhadgePosted Dec 17, 2011, 5:30 AM
1)Use Row_added event of datagridview
2)In this event,Write Code of inserting record in database
Pravin GhadgePosted Dec 17, 2011, 5:44 AM
u can use
Row_Added event:
if(datagridview.row.count>0)
{
da = new SqlDataAdapter();
DataRow vDr;
da.SelectCommand = new SqlCommand();
da.SelectCommand.CommandType = CommandType.Text;
vCmBld = new SqlCommandBuilder(da);
da.SelectCommand.Connection = con;
da.SelectCommand.CommandText = "Select * from tablname";
da.Fill(vDs, "GradeDGV");
vDr = vDs.Tables["GradeDGV_PAYMENT"].NewRow();
vDr["SrNo"] = dataGridView1.Rows[datagridvew.rows.count].Cells["SrNo"].Value;
//specifed ur column name
vDs.Tables["GradeDGV"].Rows.Add(vDr);
da.Update(vDs, "GradeDGV");
vDs.Dispose();
da.Dispose();
}
shubhangi khandalePosted Dec 17, 2011, 5:36 AM
but how to add records which is enter in cell.
using cell class this records insert in datagridview only not in database table