sorting datagrid

D

Derrick

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top