sorting datagrid

Discussion in 'ASP .Net Datagrid Control' started by Derrick, Mar 28, 2006.

  1. Derrick

    Derrick Guest

    Hi

    I have a datagrid that has its columns added dynamicly at run time. When I
    click on one of the new columns, the sort event handler is not being fired.

    My troubleshooting steps so far:
    - I created the colums at design time, and the event handler caught the
    event.
    - I used the same datagrid with the design time columns created, and ran my
    code. My code clears the columns, then adds new ones. Interesting result:
    if the column was created in design time, cleared, then added back at run
    time, the event handler caught the event. the event handler did not catch
    the event fire on new columns.

    Following is a code snippet:

    <<
    dgStats.Columns.Clear()
    Dim cFirstName As New StatsHyperLinkColumn("F Name", "firstName
    ASC", "firstName", "player_id", "player.aspx?id={0}")
    Dim cLastName As New StatsHyperLinkColumn("L Name", "lastName ASC",
    "lastName", "player_id", "player.aspx?id={0}")
    With dgStats.Columns
    .Add(cFirstName)
    .Add(cLastName)
    End With
    >>


    and the supporting class

    <<
    Public Class StatsHyperLinkColumn
    Inherits HyperLinkColumn
    Public Sub New()
    End Sub

    Public Sub New(ByVal strHeaderText As String, ByVal strSortExpression As
    String, _
    ByVal strDataTextField As String, ByVal
    strDataNavigateUrlField As String, _
    ByVal strNavigateUrlFormatString As String)
    With Me
    .ItemStyle.Wrap = False
    .Visible = True
    .HeaderText = strHeaderText
    .HeaderStyle.Wrap = False
    .SortExpression = strSortExpression
    .DataTextField = strDataTextField
    .DataNavigateUrlField = strDataNavigateUrlField
    .DataNavigateUrlFormatString = strNavigateUrlFormatString
    End With
    End Sub

    End Class
    >>


    Thanks for any help or insight.

    Derrick
    Derrick, Mar 28, 2006
    #1
    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. Replies:
    2
    Views:
    1,423
    James Kanze
    Jul 6, 2010
  2. AlainCD
    Replies:
    0
    Views:
    204
    AlainCD
    Jan 12, 2006
  3. Jason
    Replies:
    0
    Views:
    383
    Jason
    Oct 4, 2006
  4. Tom Kirchner

    sorting by multiple criterias (sub-sorting)

    Tom Kirchner, Oct 11, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    474
    Michael Budash
    Oct 11, 2003
  5. Íéêüëáïò Êïýñáò

    Sorting a set works, sorting a dictionary fails ?

    Íéêüëáïò Êïýñáò, Jun 10, 2013, in forum: Python
    Replies:
    12
    Views:
    156
    Ulrich Eckhardt
    Jun 10, 2013
Loading...

Share This Page