this my application...when i clicking submit button it should stored on data base ...can anyone help me out..
How to save the data from grid view to sqlserver?
this my application...when i clicking submit button it should stored on data base ...can anyone help me out..
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Joxin Stanly181 reputationPosted Sep 11, 2013, 3:31 AM EDT
i have pasted sample code .. it may help give you some idea
foreach (GridViewRow row in urgridname.Rows)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["constring"]);
SqlCommand cmd = new SqlCommand();
//find controls value like below
string qty = (row.FindControl("txtQty") as TextBox).Text // in case of textbox
string name = (row.FindControl("txtName") as TextBox).Text
cmd.CommandText = "INSERT INTO YOUR_TABLE_NAME (NAME, CITY) VALUES ('" name + "','" + qty + "')";
cmd.ExecuteNonQuery();
}
selva kumarRank #2,987 · 483 reputationPosted Sep 11, 2013, 11:34 PM EDT