2011-10-10 74 views
0

我有一个gridview,因为我在项目模板中使用超过5个文本框我想插入文本框中存在的值到表任何主体plz给你的sugesstion如何插入在gridview中存在的文本框的值

我尝试以下方法其示出错误我写在按钮点击事件

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"); 

回答

1

步骤这些行:

  1. 遍历Rows集合GridView
  2. 使用FindControl方法获取Cells集合中每个TextBox的引用。
  3. 通过ADO.NET provider准备SQL - INSERT语句插入行或使用Entity framework.
+0

亚我试图FindControl方法其示值误差,供您参考这里我贴我的代码 – kaarthikeyan

相关问题