110,538
社区成员
发帖
与我相关
我的任务
分享
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex != -1)
{
int id = e.Row.RowIndex + 1;
e.Row.Cells[0].Text = id.ToString();
}
}
<asp:BoundField DataField="号码" HeaderText="编号" ReadOnly="True" />
dataGridView1.RowStateChanged += (s, e) =>
{
if (e.Row.IsNewRow)
{
e.Row.HeaderCell.Value = string.Empty;
}
else
{
e.Row.HeaderCell.Value = (e.Row.Index + 1).ToString();
}
};
不知道你说的是不是这个?