G
Guest
I currently have a datagrid with several columns. The first column in the
DataGrid is a HyperLinkColumn. When I select a row, I would like for this
HyperlinkColumn to fire. I have the mouseover colors changing, and I have the
routine, but I can't seem to get the HyperLinkColumn to fire....
Private Sub MyDataGrid_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
MyDataGrid.ItemDataBound
'turn off highlighting...
If bHighlightDataGrid = False Then
Exit Sub
End If
If ((e.Item.ItemType = ListItemType.Pager) Or (e.Item.ItemType =
ListItemType.Header) Or (e.Item.ItemType = ListItemType.Footer)) Then
Exit Sub
End If
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='" & HighlightColor & "'")
If e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='" & AlternatingColor & "'")
Else
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='" & DefaultColor & "'")
End If
e.Item.Attributes("onclick") =
Page.GetPostBackClientHyperlink(e.Item.Cells(0).Controls(0), "")
'THIS IS THE SECTION THAT I'M ATTEMPTING TO GET THIS TO WORK.
'IF I CHANGE THE HYPERLINK TO HYPERLINKCOLUMN I GET A SYNTAX
'ERROR.
Dim MYLINK As HyperLink = CType(e.Item.Cells(0).Controls(0), HyperLink)
e.Item.Attributes("onclick") =
Page.GetPostBackClientHyperlink(MYLINK, "")
End If
End Sub
DataGrid is a HyperLinkColumn. When I select a row, I would like for this
HyperlinkColumn to fire. I have the mouseover colors changing, and I have the
routine, but I can't seem to get the HyperLinkColumn to fire....
Private Sub MyDataGrid_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
MyDataGrid.ItemDataBound
'turn off highlighting...
If bHighlightDataGrid = False Then
Exit Sub
End If
If ((e.Item.ItemType = ListItemType.Pager) Or (e.Item.ItemType =
ListItemType.Header) Or (e.Item.ItemType = ListItemType.Footer)) Then
Exit Sub
End If
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='" & HighlightColor & "'")
If e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='" & AlternatingColor & "'")
Else
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='" & DefaultColor & "'")
End If
e.Item.Attributes("onclick") =
Page.GetPostBackClientHyperlink(e.Item.Cells(0).Controls(0), "")
'THIS IS THE SECTION THAT I'M ATTEMPTING TO GET THIS TO WORK.
'IF I CHANGE THE HYPERLINK TO HYPERLINKCOLUMN I GET A SYNTAX
'ERROR.
Dim MYLINK As HyperLink = CType(e.Item.Cells(0).Controls(0), HyperLink)
e.Item.Attributes("onclick") =
Page.GetPostBackClientHyperlink(MYLINK, "")
End If
End Sub