Can't get this grid to sort no matter what - going crazy.

D

Dan

Seems like i've tried every example in the newsgroups and in
referenced articles but I just can't get this grid to sort, am I
missing something obvious?

View State = True
Allow Sorting = True
Sort Expressions in Property Builder set to Column Names

Code for Sort Command:

Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles
DataGrid1.SortCommand

Dim dv As New DataView(GridSet1.Tables("driverstatus_a"))

dv.Sort = e.SortExpression

DataGrid1.DataSource = dv
DataGrid1.DataBind()


End Sub

Any help is appreciated
Dan
(e-mail address removed)
 
D

Dan

Alvin Bruney said:
that code should work, what problems are you seeing?

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/2bz4t

Found the problem, courtesy of DataGrid Girl:

"In your ASPX, in the <asp:Datagrid declaration you've
got this:

DataSource="<%# GridSet1 %>"

Any Datagrid properties set declaratively will
override the ones you set in code, so when you set the DataSource to
the filtered DataView, it's not ever taking effect. Take this
property out of the declaration, and in your Page_Load, add a line to
set the DataSource to your GridSet1."

After I eliminated this code in the aspx, it worked fine. This is a
'gotcha', because VStudio automatically put this line in the aspx file
when it built the page - and I was on a wild goose chase thinking the
problem had to be in the vb code....

Thanks to all. Thank you datagrid girl.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top