Reputation: 11
I have one gridview ,in that i'm using more than 5 textboxes in item template i want to insert the values present in textbox to table any body plz give your sugesstion
i tried the following method its showing error i write these lines in button click event
TextBox txtprod = (TextBox)sender;
GridViewRow row = (GridViewRow)txtprod.Parent.Parent;
int rowIndex = row.RowIndex;
TextBox txtDetails
=(TextBox)GridView2.Rows[rowIndex].Cells[1].FindControl("txtProd");
TextBox txtQuoQuantity=(TextBox)GridView2.Rows[rowIndex].Cells[3].FindControl("txtQuantity");
TextBox txtTax = (TextBox)GridView2.Rows[rowIndex].Cells[6].FindControl("txtTax");
TextBox txtQuoRate = (TextBox)GridView2.Rows[rowIndex].Cells[4].FindControl("txtrate");
TextBox txtQuoDis = (TextBox)GridView2.Rows[rowIndex].Cells[5].FindControl("txtDis");
TextBox txtQuoAmount = (TextBox)GridView2.Rows[rowIndex].Cells[7].FindControl("txtAmt");
Upvotes: 0
Views: 610
Reputation: 94653
Steps:
Rows
collection of GridView
.FindControl
method to get the reference of each TextBox in the Cells
collection.SQL - INSERT
statement to insert a row via ADO.NET provider
or use Entity framework.
Upvotes: 1