//Gridview 分页中设置编号列
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //自动编号 e.Row.Cells[4].Text = (float.Parse(e.Row.Cells[4].Text)*100).ToString(); int index = e.Row.RowIndex;//获取当前点击前的行号 if (index % 2 == 0) { e.Row.BackColor = GetRgbColor("#ededed"); ; } }
<asp:TemplateField HeaderText="自增列" FooterText="自增列"> <ItemTemplate> <%# (Container.DataItemIndex+1).ToString()%>
</ItemTemplate> </asp:TemplateField>