日期:2014-05-18  浏览次数:20346 次

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();
}