Quantcast add auto number in Gridview

add auto number in Gridview

by Neon Quach 12. August 2009 03:59

Bởi việc sử dụng thuộc tính Container.DataItemIndex bạn có thể hiển thị số thứ tự tăng dần trong gridview.

add auto number in Gridview

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"

DataSourceID="SqlDataSource1" PageSize="6" AlternatingRowStyle-BackColor="#006699"

AlternatingRowStyle-ForeColor="#FFFFFF">

<Columns>

<asp:TemplateField HeaderText="Serial Number">

<ItemTemplate>

<%# Container.DataItemIndex + 1 %>

</ItemTemplate>

</asp:TemplateField>

<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />

<asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" />

</Columns>

</asp:GridView>

 

Reference

 

Tags: ,


Categories: asp.net | c# | visual studio tips

blog comments powered by Disqus

About me

I'm  currently employed as Software developer at devinition.com and also a Microsoft Certified Technology Specialist (MCTS), Microsoft Certified Professional Developer (MCPD) in Net Framework 2.0 and 3.5: Web Applications and MCTS .NET Framework 3.5, ADO.NET Applications

Powered by BlogEngine.NET 2.5.0.5 - Eco Theme by n3o Web Designers