Gridview 设置自动编号列

//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>

 

 

 

posted @ 2012-05-28 15:14  望月狼  阅读(223)  评论(0编辑  收藏  举报