为 Gridview 增加一个新的空白列,如下: <asp:BoundField HeaderText="序号"> <ItemStyle HorizontalAlign="Center" Width="26px" /> </asp:BoundField>
在 GridView RowDataBound 事件中编写代码,如下: protected void RowDataBond1(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1) { e.Row.Cells[0].Text = Convert.ToString(e.Row.RowIndex + 1);//cells[0]表示改行的第一个单元格 } } 这样就会在运行时自动创一个顺序编号的字段 |
|
转载于:https://www.cnblogs.com/zxl/archive/2009/07/23/1529459.html