select gridview row without using select button?

G

Guest

Is there a way to let the user select a gridview row by clicking anywhere in
the row (e.g. on any column)? The gridview would be readonly and I would like
to bring up a detailview of the row the user clicked on.

Thanks.
 
G

Guest

Phillip, thanks for the interesting demo. It's not quite what I was looking
for though, I was hoping to be able to select a SINGLE row by clicking in ANY
column of data without having to add an extra column fto be able to select a
row.
 
Joined
Feb 27, 2009
Messages
2
Reaction score
0
Page Validation Error Workaround

I ran across this and some other posts that proposed the same basic approach, however I ended up getting an error message related to Validation being set to true. (I don't recall the exact wording of it.)

As an alternative, I adapted the solution slightly to to hard code the 'javascript:_doPostBack()' into a string using the same variables to create the proper references. The result is that the onClick is generated with the Page.ClientScript.GetPostBackEventReference().

Sub gridView_ShowList_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)

Dim functionName As String

'Note that the gridview name is hard coded, the original code uses the sender object, but I couldn't get it to work
'in concatenating the string
functionName = "javascript:__doPostBack('gridView_ShowList'" + "," + "'" + "Select$" & e.Row.RowIndex.ToString + "')"

If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes.Add("onclick", functionName)
End If

End Sub

See thread

www[dot]aspmessageboard.com/showthread.php?t=230982
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top