Click here to Skip to main content
13,199,311 members (65,702 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

34.3K views
4 bookmarked
Posted 18 Feb 2010

Easy way to add Serial Numbers Column in Gridview

, 24 Mar 2010
Rate this:
Please Sign up or sign in to vote.
May occasions we need to give Serial numbers to our grid like 1,2,3,4,5, this I have tried my hand for a while and what I found.....I have posted it in someones questions earlier. We can give alphabets also but its usage is limited so that part is omitted. (it is somewhat tedious...

May occasions we need to give Serial numbers to our grid like 1,2,3,4,5, this I have tried my hand for a while and what I found.....


I have posted it in someones questions earlier. We can give alphabets also but its usage is limited so that part is omitted. (it is somewhat tedious also).


<asp:TemplateField>
            <HeaderTemplate>
            Serial No.</HeaderTemplate>
            <ItemTemplate>
            <asp:Label ID="lblSRNO" runat="server" 
                Text='<%#Container.DataItemIndex+1 %>'></asp:Label>
            </ItemTemplate>
            </asp:TemplateField>

This code works as same when we apply paging.


We cannot use this on BoundFields because they support only those objects who have Databinding event

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Indrajeet Sutar
Software Developer (Junior) Excel Informatics, Pune
India India
Am Indrajeet T. Sutar. I am a web developer. I am working on .net technology. I have completed my Masters in Computers and Management (people call it as MCA, MBA etc.) Apart from programming i do photography (not regularly though), traveling and reading books.

You may also be interested in...

Pro

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171020.1 | Last Updated 24 Mar 2010
Article Copyright 2010 by Indrajeet Sutar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid