How to show row number in Gridview, Repeater,ListView, FormView, DetailsView and DataList? Alternate to MSSQL Row_Number().

I was using Row_Number() to display row number in my data bound controls from long time. Every thing is working fine unless I have started using LINQ and Entity Framework. I found that Row_Number() is not supported. So I figured out anothor way to display row numbers in Asp .Net data bound controls. Hope it helps some one.


1) Gridview
2) ListView
          <%#Container.DataItemIndex+1 %>
3) FormView
            <%#Container.DataItemIndex+1 %>
3) Details View
                    <%#Container.DataItemIndex+1 %>
4) DataList
            <%#Container.ItemIndex+1 %>
5) Repeater
         <%#Container.ItemIndex+1 %>
Asp.Net Ajax Control Toolkit tutorials.
Thanks a bunch. Works like a charm
3-Oct-2013 From  Nikky Wasuna
Thanks Nikky... Glad to help you. Stay tuned for more.
10-Dec-2013 From  Anuj
Comment:hghweghuihfoif edited by Adminsitrator:Hi Sourabh kindly add appropriate comments.
21-Dec-2013 From  sourabh
26-Dec-2013 From  sanjeev garg

Give your valuable comments.

1 + 3 =

About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2024 CodingFusion
50+ C# Programs for beginners to practice