suppose DataGrid named dgCustomize, insert the following code to the first column.
<
asp:TemplateColumn
HeaderText
="No."
>
< ItemStyle HorizontalAlign ="Center" ></ ItemStyle >
< ItemTemplate >
< asp:Label runat ="server" Text ='<%# dgCustomize.CurrentPageIndex*dgCustomize.PageSize+dgCustomize.Items.Count+1 % >'>
</ asp:Label >
</ ItemTemplate >
</ asp:TemplateColumn >
< ItemStyle HorizontalAlign ="Center" ></ ItemStyle >
< ItemTemplate >
< asp:Label runat ="server" Text ='<%# dgCustomize.CurrentPageIndex*dgCustomize.PageSize+dgCustomize.Items.Count+1 % >'>
</ asp:Label >
</ ItemTemplate >
</ asp:TemplateColumn >
本文转自博客园鸟食轩的博客,原文链接:http://www.cnblogs.com/birdshome/,如需转载请自行联系原博主。