Hopefully a quick and easy one for someone this!!
I want to be able to select a row from a datagrid (and trigger my dg1_ItemCommand -> Select event) when the user clicks anywhere in the row. My code is as follows:
Private Sub dg1_ItemCreated(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dg1.ItemCreated
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.SelectedItem Then
But it doesn't work! I'm hoping it's something like a typo but I've tried a number of changes and nothing seems to work... It appears to post back but doesn't trigger the code it's supposed to. Incidentally, when someone selects the Select link the following is triggered and works correctly:
Private Sub dg1_ItemCommand(ByVal source As System.Object, ByVal e As System.Web.ui.WebControls.DataGridCommandEventArgs) Handles dg1.ItemCommand
Select Case e.CommandName
Case Is = "Select"
Dim sRowId As String = dg1.DataKeys(e.Item.ItemIndex).ToString()
Response.Redirect("mypage.aspx?id=" & sRowId, True)
Thanks in advance everyone!