Wednesday, July 9, 2008

Learned at work today

Enabling sorting of a gridview control (easy luckily):

Dim ds As New DataSet
'Call data method to populate dataset
ds = objData.whatever()
GridView1.DataSource = ds
If SortExpression <> "" Then
'Apply a sorting filter if applicable
Dim view As DataView = ds.Tables(0).DefaultView
view.Sort = SortExpression
GridView1.DataSource = view
End If

'Bind the data
GridView1.DataBind()

No comments: