asp.net c# Gridview sorting

Posted by Vanchi050585 under ASP.NET on 5/12/2011 | Points: 10 | Views : 6900 | Status : [Member] | Replies : 4
Hi friends,

i am binding data into the gridview. i have "serial no" column physically for sorting like below:

<ItemTemplate>
<%#Container.DataItemIndex+1 %>
</ItemTemplate>


Result looks like below:
serial no
1
2
3
4
5
6

but i want to display like below:
serial no
6
5
4
3
2
1


anybody tell the coding

Thanks
tvn



Responses

Posted by: Msahoo on: 5/12/2011 [Member] Starter | Points: 25

Up
0
Down
if you fetch data from sql server database then you can generate serial number with the result set of sql query and then attach that column into one data field. To generate serial number in select statement check below code :
Select DISTINCT ROW_NUMBER() OVER (ORDER BY Product_Name ASC) AS ROWID, Product_Name from Product_Master order by DESC




Thank You.

Regards,
Manoranjan Sahoo
http://www.dotnetsquare.com

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vanchi050585 on: 5/13/2011 [Member] Starter | Points: 25

Up
0
Down
hi Msahoo,

i dont have any column for that, gridview only i set the serial no.


this is my binding coding only:

<ItemTemplate>
<%#Container.DataItemIndex+1 %>
</ItemTemplate>


how to set this

Thanks
tvn

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 5/13/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
HI Vanchi050585

i think u want to ur table this format
6
5
4
3
2
1
so u use column not Container.DataItemIndex . . Container.DataItemIndex are collect row Index not Total Row Count Value

Best Regard's
Prabhakar

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 5/19/2011 [Member] [MVP] Bronze | Points: 25

Login to post response