Hi Mark,
i used the code you gave me but there is an error when sorting only:
"Unable to cast object of type 'System.String[]' to type
'System.Data.DataTable' "
at line: Dim dt As DataTable = Gridview1.DataSource
i tried several things (using string() instead of Datatable ...) but could
not find the solution.
the whole code:
Protected Sub Gridview1_Sorting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewSortEventArgs) Handles Gridview1.Sorting
Dim dt As DataTable = Gridview1.DataSource
If Not IsDBNull(dt) Then
Dim dv As DataView = New DataView(dt)
dv.Sort = e.SortExpression
Gridview1.DataSource = dv
Gridview1.DataBind()
End If
End Sub
"Mark Rae [MVP]" <> schreef in bericht
news:...
> "Vincent" <vi,@sd.cv> wrote in message
> news:...
>
>> Normally, when creating a gridview bound to a sqldatasource, the sorting
>> / paging occur automatically.
>
> Yes, but you're not using the SqlDataSource directly i.e. you're not
> setting the GridView's DataSourceID property - instead, you're using a
> custom object as the GridView's datasource e.g.
> rolesArray = Roles.GetAllRoles()
> Gridview1.DataSource = rolesArray
> Gridview1.DataBind()
>
> That's why you need to add event handlers for the sorting and paging
> functionality manually:
> http://forums.asp.net/p/956540/1177923.aspx
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net