Home > Asp.net > Generate Serial Number in Gridview in Asp.net

Generate Serial Number in Gridview in Asp.net


Many times we need to keep serial number in grid view as the first column, most of us get it through select query in stored procedure by making use of ROW_NUMBER() OVER (ORDER BY fieldname) but we can do the same thing in the aspx page where gridview is placed like this.

<asp:GridView  runat=”server” id=”gvDemo”>
 <Columns>
 <asp:TemplateField>
 <ItemTemplate>
 <%#Container.DataItemIndex+1 %>
 </ItemTemplate>
 </asp:TemplateField>
</Columns>
 </asp:GridView>
Advertisements
  1. December 21, 2009 at 5:28 am

    Very nice article. It helped me a lot. Previously I was taking counter to do the same. Thanks a lot. Keep posting good articles…

  2. January 8, 2010 at 2:54 am

    Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!

  3. Altaf
    February 19, 2010 at 5:00 am

    hey pankaj, I hope u remember me. Nice article. Many congratulations to u coz i came here through google.. Its amazing. Keep it up.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: