select gridview row without using select button?

Discussion in 'ASP .Net' started by =?Utf-8?B?RGFiYmxlcg==?=, Mar 3, 2006.

  1. 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.
    =?Utf-8?B?RGFiYmxlcg==?=, Mar 3, 2006
    #1
    1. Advertising

  2. 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/aspnet20/gridview_multiplerows_selection/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.
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Mar 3, 2006
    #2
    1. Advertising

  3. 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/aspnet20/gridview_multiplerows_selection/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.
    =?Utf-8?B?RGFiYmxlcg==?=, Mar 4, 2006
    #3
  4. 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/micro...6735d/67be65bab2c9766c?hl=en#67be65bab2c9766c

    --
    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/aspnet20/gridview_multiplerows_selection/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.
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Mar 4, 2006
    #4
  5. 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/micro...6735d/67be65bab2c9766c?hl=en#67be65bab2c9766c
    >
    > --
    > 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/aspnet20/gridview_multiplerows_selection/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.
    =?Utf-8?B?RGFiYmxlcg==?=, Mar 4, 2006
    #5
  6. =?Utf-8?B?RGFiYmxlcg==?=

    dch31969

    Joined:
    Feb 27, 2009
    Messages:
    2
    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
    dch31969, Feb 27, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fernando Lopes
    Replies:
    0
    Views:
    3,191
    Fernando Lopes
    Apr 28, 2005
  2. H5N1
    Replies:
    0
    Views:
    2,716
  3. Replies:
    5
    Views:
    658
  4. Ken Fine
    Replies:
    4
    Views:
    385
    Steven Cheng [MSFT]
    Jul 14, 2008
  5. hal
    Replies:
    0
    Views:
    172
Loading...

Share This Page