【问题标题】:New value on gridview edit modegridview 编辑模式的新值
【发布时间】:2013-11-26 12:28:54
【问题描述】:

当gridview在编辑模式下点击外部按钮时如何获取boundcolumn的新值(编辑模式下的默认文本框)。

if (grdMappingLog.HeaderRow != null)
        {
            for (int i = 0; i < grdMappingLog.HeaderRow.Cells.Count; i++)
            {
                dt.Columns.Add(grdMappingLog.HeaderRow.Cells[i].Text);
            }
        }
        foreach (GridViewRow row in grdMappingLog.Rows)
        {
            DataRow dr;
            dr = dt.NewRow();

            for (int i = 0; i < row.Cells.Count; i++)
            {
                dr[i] = row.Cells[i].Text.Replace(" ", "");
            }
            dt.Rows.Add(dr);
        }

【问题讨论】:

  • 到目前为止你有没有尝试过?
  • 检查已编辑的代码部分

标签: c# asp.net gridview


【解决方案1】:

试试这个:

TextBox txt= (TextBox)GridView1.Rows[GridView1.EditIndex].Cells[2].Controls[0];
Response.Write(txt.Text);

Cells[2]检索gridview1第2列的TextBox

【讨论】:

  • 我使用的是boundfield而不是templatefield
  • 是否可以在gridview中仅使用boundfield实现批量编辑
猜你喜欢
  • 2020-02-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多