How do you deselect a datagrid row? I tried setting me.myDataGrid.selectedIndex = -1, but that did nothing.
Adam
Adam
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private Sub dg_ItemCommand(ByVal source As Object, _
ByVal e As DataGridCommandEventArgs) Handles dg.ItemCommand
Select Case e.CommandName
Case "Select"
If Me.dgLists.SelectedIndex = e.Item.ItemIndex Then
Me.dgLists.SelectedIndex = -1
Else
Me.dgLists.SelectedIndex = e.Item.ItemIndex
End If
End Select
End Sub
<asp:DataGrid id=dg runat=server [b]OnItemDataBound=dgResults_IDB[/b]></asp:DataGrid>
Sub dgResults_IDB(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver';this.style.foreColor='White';this.style.cursor='hand'")
Dim button As LinkButton = CType(e.Item.Cells(0).Controls(0), LinkButton)
e.Item.Attributes("onclick") = Page.GetPostBackClientHyperlink(button, "")
If e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='White'")
Else
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='linen'")
End If
End Select
End Sub