> "Vincent" <vi,@sd.cv> wrote in message
> news:eFuzOWydIHA.4728@TK2MSFTNGP03.phx.gbl...
>
>> "Mark Rae [MVP]" <mark@markNOSPAMrae.net> schreef in bericht
>> news:OwjVKmtdIHA.4684@TK2MSFTNGP06.phx.gbl...
>>> "Vincent" <vi,@sd.cv> wrote in message
>>> news:embJoXtdIHA.4396@TK2MSFTNGP02.phx.gbl...
>>>
>>>> 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 >>
>> 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
>
> Well, there would be... A DataTable is a DataTable datatype (obviously!),
> but a GridView's DataSource is an object datatype so that various
> datatypes can be used as datasources for databound controls - you can't
> dimension a DataTable as an object directly... I can only imagine that
> you're not using Option Strict, otherwise I'm pretty sure your code
> wouldn't have compiled - it certainly wouldn't have compiled in C#...
>
>> i tried several things (using string() instead of Datatable ...) but
>> could not find the solution.
>
> Try this:
> Dim dt As DataTable = DirectCast(Gridview1.DataSource, DataTable)
>
>
> --
> Mark Rae
> ASP.NET MVP
>
http://www.markrae.net