本文介绍了在Gridview Rowedit中如何将值传递给变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想选择'grvcart'的'col1'中的值并将其传递给可变的'v_rownumber'。下面是我的代码:



I want to select the value in 'col1' of 'grvcart' and pass it to a vairable 'v_rownumber'. Hereunder is my code:

protected void grvcart_RowEditing(object sender, GridViewEditEventArgs e)
   {
      int rowIndex = Convert.ToInt32(e.NewEditIndex);
      v_rownumber=grvcart.RowEditing.Cells[1].Text;
      //v_qty = grvcart.RowEditing.Cell[3].Text;
       if (ViewState["CurrentTable"] != null)
         {
             DataTable dt = (DataTable)ViewState["CurrentTable"];
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 if (Convert.ToInt32(dt.Rows[i]["rownumber"]) ==Convert.ToInt32(v_rownumber))
                 {
                     dt.Rows[i]["col3"] = v_qty;
                 }
             }
         }
   }







我在'v_rownumber = grvcart.RowEditing.Cells [1]。文本中收到错误;'

说明:'




I get an error at 'v_rownumber=grvcart.RowEditing.Cells[1].Text;'
stating:'

Error   1   The event 'System.Web.UI.WebControls.GridView.RowEditing' can only appear on the left hand side of += or -= C:\prasiddhivs2008\Default.aspx.cs  281 28  C:\prasiddhivs2008\

推荐答案

v_rownumber = grvcart.Rows[e.NewEditIndex].Cells[1].Text;



如果它是 TemplateField TextBox ,那么请执行以下操作...


If it is a TemplateField TextBox, then do like below...

TextBox tbProductId = grvcart.Rows[e.NewEditIndex].Cells[1].FindControl("TBProductId") as TextBox;
v_rownumber = tbProductId.Text;


v_rownumber = grvcart.Rows[e.NewEditIndex].Cells[1].Text;





谢谢

karthik



Thanks
karthik


这篇关于在Gridview Rowedit中如何将值传递给变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 22:50