Selecting Datagrid Row by Clicking Anywhere

S

sa5webber

I'm trying to setup a datagrid in a custom control where I can select
the row with the Select column hidden and have it call the
"SelectIndexChanged" event. In the "SelectIndexChanged" I just want to
populate a textbox with an item out of the selected row.

I've implemented what seems to be the standard approach like what's
shown below to accomplishing this and the event works when selecting
the select column link, when I make it visible. However I can't get it
to work when selecting other parts of the row with the select column
visible or not. What am I missing or is there a better way to
accomplish what I'm trying to do?

Thanks

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles DataGrid1.ItemDataBound
Dim itemType As ListItemType = e.Item.ItemType
If ((itemType = ListItemType.Pager) Or _
(itemType = ListItemType.Header) Or _
(itemType = ListItemType.Footer)) Then
Return
Else
Dim button As LinkButton = _
CType(e.Item.Cells(0).Controls(0), LinkButton)
e.Item.Attributes("onclick") = _
Page.GetPostBackClientHyperlink(button, "")
End If
End Sub
 

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

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top