Tuesday, December 1, 2009

Generating Sequence Number in DataGrid with Paging

There are two ways you can generate sequence number in grid.


1. Generate Sequence Number in Datagrid from aspx page you can simply add:

<%# (DataGrid1.PageSize*DataGrid1.CurrentPageIndex)+ Container.ItemIndex+1%>


2. Generate Sequence Number in Datagrid from SQL:

SELECT ROW_NUMBER() OVER(ORDER BY ID DESC) AS SeqNumber FROM TABLE_NAME

AND Bind DataGrid as,

<%#DataBinder.Eval(Container.DataItem,"SeqNumber")%>

1 comment:

Ashvin Padhiyar said...

Thanks your post is very helpful