当前位置: 代码迷 >> ASP.NET >> 2005中的gridview怎样增加一自动增长列解决办法
  详细解决方案

2005中的gridview怎样增加一自动增长列解决办法

热度:9472   发布时间:2013-02-25 00:00:00.0
2005中的gridview怎样增加一自动增长列
2005中的gridview怎样增加一自动增长列

------解决方案--------------------------------------------------------
前面加个空白列,然后在RowDataBound事件中处理:
protected void gvTables_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex == -1)
return;

int nIndex = gvTables.PageIndex * gvTables.PageSize + e.Row.RowIndex + 1;
e.Row.Cells[0].Text = nIndex.ToString();
}

  相关解决方案