Saturday, April 18, 2009

Add numbering in gridview [VB / C#]

I also have the same problem when i first using the gridview. Gridview is a very powerful control (we do not have to code table like in PHP). So, after doing a research on several web resources, I've found this method. With this method you can add numbering in your gridview. Insert this code in your page inside the gridview codes (.aspx)

VB
--

<Columns>
<asp:TemplateField>
<ItemTemplate>
<%#Container.DataItemIndex + 1 & "."%>
</ItemTemplate>
</asp:TemplateField>
</Columns>



C#
--

<Columns>
<asp:TemplateField>
<ItemTemplate>
<%#Container.DataItemIndex + 1 + "."%>
</ItemTemplate>
</asp:TemplateField>
</Columns>

No comments:

Post a Comment