Friday, June 19, 2009

How to generate serial Number in DataList? asp.net

How to generate serial Number in DataList?


<asp:TemplateField HeaderText="SLr.No">
           <ItemTemplate>
          <asp:Label ID="lbSnNo" runat="Server" Text='<%# Container.ItemIndex + 1 %>' />
           </ItemTemplate>
</asp:TemplateField>

 

2 comments:

meera2089 said...

This code does not work well with datalist(paging enabled with paged Data Source).Can you help me?

meera2089 said...

For every page, I get number starting from 1 instead of serial number.