如果在外部按钮单击时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);
}
答案 0 :(得分:3)
试试这个:
TextBox txt= (TextBox)GridView1.Rows[GridView1.EditIndex].Cells[2].Controls[0];
Response.Write(txt.Text);
Cells [2] 在gridview1的第2列中检索TextBox