Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > select gridview row without using select button?

Reply
Thread Tools

select gridview row without using select button?

 
 
=?Utf-8?B?RGFiYmxlcg==?=
Guest
Posts: n/a
 
      03-03-2006
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.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      03-03-2006
During the GridView.RowCreated you can add a Javascript and either an
HTMLInputHidden object or a checkbox to manage the state of the selected row
on the server side. If you need an example you are welcome to look at this
demo that I have on my website:
http://www.webswapp.com/codesamples/...n/default.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Dabbler" wrote:

> 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.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGFiYmxlcg==?=
Guest
Posts: n/a
 
      03-04-2006
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.

"Phillip Williams" wrote:

> During the GridView.RowCreated you can add a Javascript and either an
> HTMLInputHidden object or a checkbox to manage the state of the selected row
> on the server side. If you need an example you are welcome to look at this
> demo that I have on my website:
> http://www.webswapp.com/codesamples/...n/default.aspx
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Dabbler" wrote:
>
> > 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.

 
Reply With Quote
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      03-04-2006
Look at this thread which we discussed a solution using a hidden Select
CommandField on this forum a while ago:
http://groups.google.ca/group/micros...be65bab2c9766c

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Dabbler" wrote:

> 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.
>
> "Phillip Williams" wrote:
>
> > During the GridView.RowCreated you can add a Javascript and either an
> > HTMLInputHidden object or a checkbox to manage the state of the selected row
> > on the server side. If you need an example you are welcome to look at this
> > demo that I have on my website:
> > http://www.webswapp.com/codesamples/...n/default.aspx
> >
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "Dabbler" wrote:
> >
> > > 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.

 
Reply With Quote
 
=?Utf-8?B?RGFiYmxlcg==?=
Guest
Posts: n/a
 
      03-04-2006
Thanks, that was more like what I was looking for.

"Phillip Williams" wrote:

> Look at this thread which we discussed a solution using a hidden Select
> CommandField on this forum a while ago:
> http://groups.google.ca/group/micros...be65bab2c9766c
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Dabbler" wrote:
>
> > 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.
> >
> > "Phillip Williams" wrote:
> >
> > > During the GridView.RowCreated you can add a Javascript and either an
> > > HTMLInputHidden object or a checkbox to manage the state of the selected row
> > > on the server side. If you need an example you are welcome to look at this
> > > demo that I have on my website:
> > > http://www.webswapp.com/codesamples/...n/default.aspx
> > >
> > > --
> > > HTH,
> > > Phillip Williams
> > > http://www.societopia.net
> > > http://www.webswapp.com
> > >
> > >
> > > "Dabbler" wrote:
> > >
> > > > 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.

 
Reply With Quote
 
dch31969 dch31969 is offline
Junior Member
Join Date: Feb 2009
Posts: 2
 
      02-27-2009
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview row databound event - can't get past the 1st row of gridview maurban@gmail.com ASP .Net 5 10-13-2006 09:37 PM
GridView nested in DataList - refreshing corresponding DataList row after updating GridView row H5N1 ASP .Net 0 04-26-2006 11:41 PM
Selecting a row in asp.net 2.0 GridView by clicking anywhere in the row misiek ASP .Net 0 02-20-2006 08:26 AM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Highlight the row and click anywhere to select a row in a GridView Fernando Lopes ASP .Net 0 04-28-2005 12:24 PM



Advertisments