Nadeem Nadeem - 1 month ago 7
ASP.NET (C#) Question

Auto generate serial no in gridview

I want to generate serial no in gridview asp.net.
How can I do it?

Answer

try this

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

Note : DataItemIndex - Gets the index of the DataItem in the underlying DataSet.

Comments