參考: https://blog.xuite.net/xiaolian/blog/46204394-%E5%9C%A8GridView%E4%B8%AD%E5%8A%A0%E5%85%A5%E8%87%AA%E5%8B%95%E7%B7%A8%E8%99%9F%E7%9A%84%E5%BA%8F%E8%99%9F
在Aspx檔案中GridView表格內插入一個欄位,在第一欄加上TemplateField的欄位,語法如下: 流水號從第一筆編起 <asp:TemplateField HeaderText="序號"> <ItemTemplate> <%#GridView1.PageIndex * GridView1.PageSize + GridView1.Rows.Count + 1%> </ItemTemplate> <HeaderStyle Wrap="False" /> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> </asp:TemplateField> OR <asp:TemplateField HeaderText="序號"> <ItemTemplate> <%#Container.DataItemIndex + 1%> </ItemTemplate> <HeaderStyle Wrap="False" /> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> </asp:TemplateField> 流水號每頁從1編起 <asp:TemplateField HeaderText="序號"> <ItemTemplate> <%#Container.DisplayIndex + 1%> </ItemTemplate> <HeaderStyle Wrap="False" /> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> </asp:TemplateField>