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