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
Sno
<%#(Container.DataItemIndex+1)%>
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 %>