tags:

views:

182

answers:

1

With a gridview control bound to a sql data source, i want to display a column named ID. The ID should display the row number for each row. How would I go about binding this to rowindex instead of the ID column from the database?

+1  A: 

Hello sj, For that I would use the ROW_NUMBER() function which is new in SQL Server 2005. This function returns rownumber in the recordset that is being returned. There is an excellent post by ScottGu. HTH, Valve.

Valentin Vasiliev
Valve: Thanks for the info, Now If my data source changes to a objectdatasource bound to a List<T>, my dataset is transformed into List<T>. Can I still use ROW_NUMBER()