Suppose you have a button called btnSubmit then on click of submit button you can write following code
to database for further processing in stored procedure you can split this values and add to database this approach will save your multiple hit to
database
protected void GridView1_Click(object sender, EventArgs e) { foreach (GridViewRow row in grd.Rows) { if (row.RowType == DataControlRowType.DataRow) { TextBox txt = (TextBox)row.Cells[1].FindControl("TextBox1"); if (txt != null && !string.IsNullOrEmpty(txt.Text)) { string stDescription = row.Cells[0].Text; string stMeasurement = row.Cells[2].Text; // Now you have all the values // i.e. Description,Measurement and the textbox value
entered against this two // now you can add this values to database by passing it to some stored procedure } } } }Another idea is to loop all rows and concatinate this strings in one single string builder seperated by some unique delimiter and pass this value
to database for further processing in stored procedure you can split this values and add to database this approach will save your multiple hit to
database



1 comments:
Post a Comment