首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-01-13 
2005中的gridview怎样增加一自动增长列2005中的gridview怎样增加一自动增长列[解决办法]前面加个空白列,然

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

热点排行