Problem with Sorting Web Datagrid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stuart

    Problem with Sorting Web Datagrid

    Hi There

    I have a datagrid with a Select(LinkButt on) Column followed by several Bound
    Columns.

    I have enabled the columns to sort and created the correct event handler (I
    think) - however the crux of my problem is that when I click on one of the
    column headers to sort by it the ItemCommand fires rather than the
    SortCommand.

    in the .aspx file I have:
    OnItemCommand=" SalesGroupIniti al_ItemCommand"
    OnSortCommand=" SalesGroupIniti al_SortCommand"

    which correlate to the .aspx.vb file (I also have an OnItemDatabound event
    if that is of any significance)

    I have not included the code at this juncture as it is a flat case of the
    wrong event firing when I click the Column Header

    Any ideas would be very much appreciated

    Stuart
  • Joe Fallon

    #2
    Re: Problem with Sorting Web Datagrid

    I think the ItemCommand handler will run even when you sort. (It does when
    you page.)

    Protected Sub SalesGroupIniti al_ItemCommand( ByVal source As Object, ByVal e
    As DataGridCommand EventArgs)
    'Grid paging causes this event to fire (among others) and
    e.Item.ItemInde x=-1 so we should avoid an error by coding for this case.

    If e.Item.ItemInde x >= 0 Then
    'now do stuff
    End If

    End Sub

    Check that your Sort signature includes a Handles statement.
    Sometimes they "disappear" - if you re-name the grid in the .aspx they will
    go away and you have to manually add them back.
    --
    Joe Fallon



    "Stuart" <Stuart@discuss ions.microsoft. com> wrote in message
    news:E47D35B2-3746-44AE-9409-4244939E16A2@mi crosoft.com...[color=blue]
    > Hi There
    >
    > I have a datagrid with a Select(LinkButt on) Column followed by several
    > Bound
    > Columns.
    >
    > I have enabled the columns to sort and created the correct event handler
    > (I
    > think) - however the crux of my problem is that when I click on one of the
    > column headers to sort by it the ItemCommand fires rather than the
    > SortCommand.
    >
    > in the .aspx file I have:
    > OnItemCommand=" SalesGroupIniti al_ItemCommand"
    > OnSortCommand=" SalesGroupIniti al_SortCommand"
    >
    > which correlate to the .aspx.vb file (I also have an OnItemDatabound event
    > if that is of any significance)
    >
    > I have not included the code at this juncture as it is a flat case of the
    > wrong event firing when I click the Column Header
    >
    > Any ideas would be very much appreciated
    >
    > Stuart[/color]


    Comment

    • Stuart

      #3
      Re: Problem with Sorting Web Datagrid

      Spot on !

      Thanks very much Joe

      "Joe Fallon" wrote:
      [color=blue]
      > I think the ItemCommand handler will run even when you sort. (It does when
      > you page.)
      >
      > Protected Sub SalesGroupIniti al_ItemCommand( ByVal source As Object, ByVal e
      > As DataGridCommand EventArgs)
      > 'Grid paging causes this event to fire (among others) and
      > e.Item.ItemInde x=-1 so we should avoid an error by coding for this case.
      >
      > If e.Item.ItemInde x >= 0 Then
      > 'now do stuff
      > End If
      >
      > End Sub
      >
      > Check that your Sort signature includes a Handles statement.
      > Sometimes they "disappear" - if you re-name the grid in the .aspx they will
      > go away and you have to manually add them back.
      > --
      > Joe Fallon
      >
      >
      >
      > "Stuart" <Stuart@discuss ions.microsoft. com> wrote in message
      > news:E47D35B2-3746-44AE-9409-4244939E16A2@mi crosoft.com...[color=green]
      > > Hi There
      > >
      > > I have a datagrid with a Select(LinkButt on) Column followed by several
      > > Bound
      > > Columns.
      > >
      > > I have enabled the columns to sort and created the correct event handler
      > > (I
      > > think) - however the crux of my problem is that when I click on one of the
      > > column headers to sort by it the ItemCommand fires rather than the
      > > SortCommand.
      > >
      > > in the .aspx file I have:
      > > OnItemCommand=" SalesGroupIniti al_ItemCommand"
      > > OnSortCommand=" SalesGroupIniti al_SortCommand"
      > >
      > > which correlate to the .aspx.vb file (I also have an OnItemDatabound event
      > > if that is of any significance)
      > >
      > > I have not included the code at this juncture as it is a flat case of the
      > > wrong event firing when I click the Column Header
      > >
      > > Any ideas would be very much appreciated
      > >
      > > Stuart[/color]
      >
      >
      >[/color]

      Comment

      Working...