'Gridview1' fired event Sorting which wasn't handled

Discussion in 'ASP .Net' started by Vincent, Feb 23, 2008.

  1. Vincent

    Vincent Guest

    Hi,

    I created a gridview bound to the roles tables with this code:
    rolesArray = Roles.GetAllRoles()
    Gridview1.DataSource = rolesArray
    Gridview1.DataBind()

    The gridview has following classic properties:
    <asp:GridView runat="server" id="Gridview1" AllowPaging="True"
    AllowSorting="true"
    pagesize="3" />

    When clicking on the bar containing the pagenumber of the gridview in order
    to go the next page, i get:
    "The GridView 'Gridview1' fired event PageIndexChanging which wasn't
    handled."

    When i click on the field for sorting, i get the error:
    "The GridView 'Gridview1' fired event Sorting which wasn't handled"

    Thanks for help
    Vincent
     
    Vincent, Feb 23, 2008
    #1
    1. Advertising

  2. "Vincent" <vi,@sd.cv> wrote in message
    news:%...

    > When clicking on the bar containing the pagenumber of the gridview in
    > order to go the next page, i get:
    > "The GridView 'Gridview1' fired event PageIndexChanging which wasn't
    > handled."
    >
    > When i click on the field for sorting, i get the error:
    > "The GridView 'Gridview1' fired event Sorting which wasn't handled"


    That's because you haven't wired up the paging and sorting events...

    <asp:GridView runat="server" id="Gridview1"
    AllowPaging="True" AllowSorting="true" pagesize="3"
    OnPageIndexChanging="Gridview1_PageIndexChanging"
    OnSorting="Gridview1_Sorting"
    />

    protected void Gridview1_PageIndexChanging(object sender,
    GridViewPageEventArgs e)
    {
    // do something
    }

    protected void Gridview1_Sorting(object sender, GridViewSortEventArgs e)
    {
    // do something
    }


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Feb 23, 2008
    #2
    1. Advertising

  3. Vincent

    Vincent Guest

    Thanks for your reply.

    Normally, when creating a gridview bound to a sqldatasource, the sorting /
    paging occur automatically. This is new to me so what code do you mean with
    // do something
    Does it exist something like 'sort' or 'paging' ...?


    Mark Rae [MVP]" <> schreef in bericht
    news:%...
    > "Vincent" <vi,@sd.cv> wrote in message
    > news:%...
    >
    >> When clicking on the bar containing the pagenumber of the gridview in
    >> order to go the next page, i get:
    >> "The GridView 'Gridview1' fired event PageIndexChanging which wasn't
    >> handled."
    >>
    >> When i click on the field for sorting, i get the error:
    >> "The GridView 'Gridview1' fired event Sorting which wasn't handled"

    >
    > That's because you haven't wired up the paging and sorting events...
    >
    > <asp:GridView runat="server" id="Gridview1"
    > AllowPaging="True" AllowSorting="true" pagesize="3"
    > OnPageIndexChanging="Gridview1_PageIndexChanging"
    > OnSorting="Gridview1_Sorting"
    > />
    >
    > protected void Gridview1_PageIndexChanging(object sender,
    > GridViewPageEventArgs e)
    > {
    > // do something
    > }
    >
    > protected void Gridview1_Sorting(object sender, GridViewSortEventArgs e)
    > {
    > // do something
    > }
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Vincent, Feb 24, 2008
    #3
  4. "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
     
    Mark Rae [MVP], Feb 24, 2008
    #4
  5. Vincent

    Vincent Guest

    Thanks, i'll read it

    "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
     
    Vincent, Feb 24, 2008
    #5
  6. Vincent

    Vincent Guest

    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
     
    Vincent, Feb 24, 2008
    #6
  7. "Vincent" <vi,@sd.cv> wrote in message
    news:...

    > "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

    >
    > 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
     
    Mark Rae [MVP], Feb 24, 2008
    #7
  8. Vincent

    Vincent Guest

    Thanks again, but i still get the same error at line:
    Dim dt As DataTable = DirectCast(Gridview1.DataSource, DataTable)



    "Mark Rae [MVP]" <> schreef in bericht
    news:...
    > "Vincent" <vi,@sd.cv> wrote in message
    > news:...
    >
    >> "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

    >>
    >> 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
     
    Vincent, Feb 24, 2008
    #8
  9. "Vincent" <vi,@sd.cv> wrote in message
    news:%23%...

    [top-posting corrected]

    >>> 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)

    >
    > Thanks again, but i still get the same error at line:
    > Dim dt As DataTable = DirectCast(Gridview1.DataSource, DataTable)


    Hmm - OK... What datatype is GridView1.DataSource? Can it even be cast to a
    DataTable type...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Feb 24, 2008
    #9
  10. Vincent

    Vincent Guest

    The datasource are the roles from the table 'aspnet_roles' created when
    creating membership users:
    so the datasource is of type array string.

    dim rolesArray() As String
    rolesArray = Roles.GetAllRoles()
    Gridview1.DataSource = rolesArray
    Gridview1.DataBind()

    Thanks


    "Mark Rae [MVP]" <> schreef in bericht
    news:...
    > "Vincent" <vi,@sd.cv> wrote in message
    > news:%23%...
    >
    > [top-posting corrected]
    >
    >>>> 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)

    >>
    >> Thanks again, but i still get the same error at line:
    >> Dim dt As DataTable = DirectCast(Gridview1.DataSource, DataTable)

    >
    > Hmm - OK... What datatype is GridView1.DataSource? Can it even be cast to
    > a DataTable type...?
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Vincent, Feb 25, 2008
    #10
  11. "Vincent" <vi,@sd.cv> wrote in message
    news:%...

    [top-posting corrected again]

    >>>>> 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)
    >>>
    >>> Thanks again, but i still get the same error at line:
    >>> Dim dt As DataTable = DirectCast(Gridview1.DataSource, DataTable)

    >>
    >> Hmm - OK... What datatype is GridView1.DataSource? Can it even be cast to
    >> a DataTable type...?

    >
    > The datasource are the roles from the table 'aspnet_roles' created when
    > creating membership users:
    > so the datasource is of type array string.
    >
    > dim rolesArray() As String
    > rolesArray = Roles.GetAllRoles()
    > Gridview1.DataSource = rolesArray
    > Gridview1.DataBind()


    OK, so the datasource for the GridView *isn't* a DataTable - it's a string
    array... That's fine, of course, except that you're trying to dimension a
    DataTable variable and populate it with a string array - that's never going
    to work without an explicit conversion...

    In the link I suggested, the sorting method relies on the fact that the
    datasource of the GridView is a DataTable, from which a DataView object can
    be created. This isn't the case with string arrays, so you'll have to write
    your own sorting routine - something like this:
    http://www.thescripts.com/forum/thread384129.html


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Feb 25, 2008
    #11
  12. Vincent

    Vincent Guest

    ok, thanks

    "Mark Rae [MVP]" <> schreef in bericht
    news:%...
    > "Vincent" <vi,@sd.cv> wrote in message
    > news:%...
    >
    > [top-posting corrected again]
    >
    >>>>>> 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)
    >>>>
    >>>> Thanks again, but i still get the same error at line:
    >>>> Dim dt As DataTable = DirectCast(Gridview1.DataSource, DataTable)
    >>>
    >>> Hmm - OK... What datatype is GridView1.DataSource? Can it even be cast
    >>> to a DataTable type...?

    >>
    >> The datasource are the roles from the table 'aspnet_roles' created when
    >> creating membership users:
    >> so the datasource is of type array string.
    >>
    >> dim rolesArray() As String
    >> rolesArray = Roles.GetAllRoles()
    >> Gridview1.DataSource = rolesArray
    >> Gridview1.DataBind()

    >
    > OK, so the datasource for the GridView *isn't* a DataTable - it's a string
    > array... That's fine, of course, except that you're trying to dimension a
    > DataTable variable and populate it with a string array - that's never
    > going to work without an explicit conversion...
    >
    > In the link I suggested, the sorting method relies on the fact that the
    > datasource of the GridView is a DataTable, from which a DataView object
    > can be created. This isn't the case with string arrays, so you'll have to
    > write your own sorting routine - something like this:
    > http://www.thescripts.com/forum/thread384129.html
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Vincent, Feb 25, 2008
    #12
  13. Vincent

    Jerry Hui Guest

    If you are setting the DataSource of your GridView programmatically, set its DataSourceID property instead of DataSource; suddenly you'll be able to use the default sorting function.



    Vincent wrote:

    'Gridview1' fired event Sorting which wasn't handled
    23-Feb-08

    Hi

    I created a gridview bound to the roles tables with this code
    rolesArray = Roles.GetAllRoles(
    Gridview1.DataSource = rolesArra
    Gridview1.DataBind(

    The gridview has following classic properties
    <asp:GridView runat="server" id="Gridview1" AllowPaging="True"
    AllowSorting="true
    pagesize="3" /

    When clicking on the bar containing the pagenumber of the gridview in order
    to go the next page, i get
    "The GridView 'Gridview1' fired event PageIndexChanging which wasn't
    handled.

    When i click on the field for sorting, i get the error
    "The GridView 'Gridview1' fired event Sorting which wasn't handled

    Thanks for hel
    Vincent

    Previous Posts In This Thread:

    On Saturday, February 23, 2008 4:50 PM
    Vincent wrote:

    'Gridview1' fired event Sorting which wasn't handled
    Hi

    I created a gridview bound to the roles tables with this code
    rolesArray = Roles.GetAllRoles(
    Gridview1.DataSource = rolesArra
    Gridview1.DataBind(

    The gridview has following classic properties
    <asp:GridView runat="server" id="Gridview1" AllowPaging="True"
    AllowSorting="true
    pagesize="3" /

    When clicking on the bar containing the pagenumber of the gridview in order
    to go the next page, i get
    "The GridView 'Gridview1' fired event PageIndexChanging which wasn't
    handled.

    When i click on the field for sorting, i get the error
    "The GridView 'Gridview1' fired event Sorting which wasn't handled

    Thanks for hel
    Vincent

    On Saturday, February 23, 2008 5:04 PM
    Mark Rae [MVP] wrote:

    Re: 'Gridview1' fired event Sorting which wasn't handled
    "Vincent" <vi,@sd.cv> wrote in message
    news:%..

    That's because you haven't wired up the paging and sorting events..

    <asp:GridView runat="server" id="Gridview1
    AllowPaging="True" AllowSorting="true" pagesize="3
    OnPageIndexChanging="Gridview1_PageIndexChanging"
    OnSorting="Gridview1_Sorting
    /

    protected void Gridview1_PageIndexChanging(object sender,
    GridViewPageEventArgs e

    // do somethin


    protected void Gridview1_Sorting(object sender, GridViewSortEventArgs e

    // do somethin


    --
    Mark Ra
    ASP.NET MV
    http://www.markrae.net

    On Sunday, February 24, 2008 6:10 AM
    Vincent wrote:

    Thanks for your reply.
    Thanks for your reply

    Normally, when creating a gridview bound to a sqldatasource, the sorting /
    paging occur automatically. This is new to me so what code do you mean wit
    // do somethin
    Does it exist something like 'sort' or 'paging' ...

    Mark Rae [MVP]" <> schreef in bericht
    news:%...

    On Sunday, February 24, 2008 6:36 AM
    Mark Rae [MVP] wrote:

    Re: 'Gridview1' fired event Sorting which wasn't handled
    "Vincent" <vi,@sd.cv> wrote in message
    news:..

    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 = rolesArra
    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.asp

    --
    Mark Ra
    ASP.NET MV
    http://www.markrae.net

    On Sunday, February 24, 2008 12:23 PM
    Vincent wrote:

    Re: 'Gridview1' fired event Sorting which wasn't handled
    Thanks, i'll read i

    "Mark Rae [MVP]" <> schreef in bericht

    On Sunday, February 24, 2008 3:40 PM
    Vincent wrote:

    Hi Mark,i used the code you gave me but there is an error when sorting
    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.DataSourc

    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:...

    On Sunday, February 24, 2008 4:12 PM
    Mark Rae [MVP] wrote:

    Re: 'Gridview1' fired event Sorting which wasn't handled
    "Vincent" <vi,@sd.cv> wrote in message
    news:...


    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#...


    Try this:
    Dim dt As DataTable = DirectCast(Gridview1.DataSource, DataTable)


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net

    On Sunday, February 24, 2008 5:13 PM
    Vincent wrote:

    Re: 'Gridview1' fired event Sorting which wasn't handled
    Thanks again, but i still get the same error at line:
    Dim dt As DataTable = DirectCast(Gridview1.DataSource, DataTable)



    "Mark Rae [MVP]" <> schreef in bericht

    On Sunday, February 24, 2008 6:28 PM
    Mark Rae [MVP] wrote:

    Re: 'Gridview1' fired event Sorting which wasn't handled
    [top-posting corrected]


    Hmm - OK... What datatype is GridView1.DataSource? Can it even be cast to a
    DataTable type...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net

    On Monday, February 25, 2008 2:43 AM
    Vincent wrote:

    The datasource are the roles from the table 'aspnet_roles' created when
    The datasource are the roles from the table 'aspnet_roles' created when
    creating membership users:
    so the datasource is of type array string.

    dim rolesArray() As String
    rolesArray = Roles.GetAllRoles()
    Gridview1.DataSource = rolesArray
    Gridview1.DataBind()

    Thanks


    "Mark Rae [MVP]" <> schreef in bericht
    news:...

    On Monday, February 25, 2008 5:50 AM
    Mark Rae [MVP] wrote:

    Re: 'Gridview1' fired event Sorting which wasn't handled
    "Vincent" <vi,@sd.cv> wrote in message
    news:%...

    [top-posting corrected again]


    OK, so the datasource for the GridView *isn't* a DataTable - it's a string
    array... That's fine, of course, except that you're trying to dimension a
    DataTable variable and populate it with a string array - that's never going
    to work without an explicit conversion...

    In the link I suggested, the sorting method relies on the fact that the
    datasource of the GridView is a DataTable, from which a DataView object can
    be created. This isn't the case with string arrays, so you'll have to write
    your own sorting routine - something like this:
    http://www.thescripts.com/forum/thread384129.html


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net

    On Monday, February 25, 2008 8:42 AM
    Vincent wrote:

    Re: 'Gridview1' fired event Sorting which wasn't handled
    ok, thanks

    "Mark Rae [MVP]" <> schreef in bericht

    On Thursday, March 26, 2009 7:09 AM
    Jaimee Kaiser wrote:

    'Gridview1' fired event Sorting which wasn't handled
    Hi Mark..

    I have a similar problem. My array is a type of an object and not a string array or anything like that. My array looks like this in the gridview:

    Nr Contact Nr Customer Nr Date .... and so on
    -- ---------- ----------- ---- ....
    s1 K123 123 31.01.08
    s2 K123 123 30.01.08
    s3 K123 123 25.01.08

    I want to sort by Nr (allowing the user to click on the header link for sorting).

    I have tried numerous solutions to try and sort this gridview and I am absolutely at a wall.

    My datasource looks like this:

    servOrders = new GetServiceOrders();

    ServiceHeader.ServHead[] tempOrders = new ServiceHeader.ServHead[100];

    tempOrders = servOrders.GetServHeadByCustNo((string)Session["CustomerNo"], "Pending|In Process");

    GridView2.DataSource = tempOrders;
    GridView2.Databind();

    I must use this way for datasource because it comes out of a deeper web service that gets the data live from Microsoft Navision (ie... the fields can change at anytime and the fields must be dynamic).

    The temp order that is returned has 26 dimensions
    (for example say 3 rows returned and in each row there is x amount of dimensions (field property and field value):
    {0} --
    Nr - Nr
    Nr.value - S1
    Contact_Nr - Contact Nr
    Contact_Nr.value - K123
    ... and so one
    {1} --
    Nr - Nr
    Nr.value - S2
    Contact_Nr - Contact Nr
    Contact_Nr.value - K123
    ... and so one

    How on earth do I sort this?? I can't put it into a datatable.. I tried that and the datatable kept returning as null.

    Help or advice would be greatly appreciated.


    Submitted via EggHeadCafe - Software Developer Portal of Choice
    DataContractSerializer Basics
    http://www.eggheadcafe.com/tutorial...c-94d2f3b1b265/datacontractserializer-ba.aspx
     
    Jerry Hui, Mar 19, 2010
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Klemt
    Replies:
    1
    Views:
    474
    John Saunders
    Jul 9, 2004
  2. Arjen
    Replies:
    3
    Views:
    69,550
    JackMcKenzie
    Nov 1, 2007
  3. rote
    Replies:
    0
    Views:
    1,807
  4. egsdar
    Replies:
    0
    Views:
    3,260
    egsdar
    Nov 4, 2008
  5. Jason
    Replies:
    0
    Views:
    412
    Jason
    Oct 4, 2006
Loading...

Share This Page