|
-
Oct 14th, 2003, 09:28 AM
#1
Thread Starter
Fanatic Member
grid sort
Hi,
in my asp.net project, I am populating a datagrid ( on a web form ) using a datareader (GetAllTrades). See below...
With dgNewTrades
.DataSource = oCatTMS.GetAllTrades
.DataKeyField = "tnum"
.DataBind()
End With
The AllowSorting property is set to true.
But I can not sort the data. When I place the mouse over the column names, I will not get the hyperlinks.
Any thoughts?
Thanks
-
Oct 14th, 2003, 11:08 AM
#2
There is quite a lot to do before sorting will work, as well as allowsorting=true you will need to set an on sort event such as
OnSortCommand="sort_grid"
Code:
Sub Sort_Grid(ByVal sender As Object, ByVal e As DataGridSortCommandEventArgs)
SortExpression = e.SortExpression.ToString()
gridLeaderBoard.DataSource = createDataSource()
gridLeaderBoard.DataBind()
End Sub
When you want to sort you have to resort the datasource and then rebind the grid to it's datasource. I do this by loading data from my database into a datatable, then creating a dataview (sorted by sortExpression).
Hope this helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|