Results 1 to 6 of 6

Thread: [RESOLVED] navigate pages through datagrid item

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    Resolved [RESOLVED] navigate pages through datagrid item

    *control naming error its Gridview not datagrid

    Hi, I have search page using gridivew with boundfield on it. And I want to do something extra by making the full row clickable instead of having hyperlink control in specific column or make the image a hyperlink itself. I've read some post regarding CellContentClick but not really sure how to use it. Other use AJAX... not my option at the moment as I want to keep the code simple for simple task.

    http://img820.imageshack.us/i/img1e.gif/
    Last edited by jlbantang; Mar 21st, 2011 at 08:04 AM.
    Learn something new every .001 second.

  2. #2

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    Re: navigate pages through datagrid item

    hi gary,

    Not really, my apology if i get you lost. Take this sample

    Code:
    DirectCast(e.Row.FindControl("showbutton"), Button).Attributes.Add("onclick", "window.open('mrecipe.aspx?id=" & e.Row.DataItem("pk_id").ToString & "','_self'); return false;")
    basically i use the showbutton for transferring details to other page but instead of having that i want to use the entire row to fire to raise a navigation event.

    Thanks.
    Learn something new every .001 second.

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: navigate pages through datagrid item

    Ok, this is simply an extension of the code that I linked to.

    The example show how to make the whole row clickable, so once you have that, you just exchange in your code.

    Gary

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    Re: navigate pages through datagrid item

    hey, thanks for the web ref. it was a good start.

    eventually i end up with the simplest code, something like these. only that i hook up row data for building querystring.

    Code:
            If e.Row.RowType = DataControlRowType.DataRow Then
                e.Row.Attributes.Add("onclick", "javascript:window.location='my_url?q=" &  e.row.dataitem("fld").tostring &";")
                
                'add hlink cursor effect   
                e.Row.Attributes.Add("onmouseover", "javascript:this.style.cursor='pointer';")
                e.Row.Attributes.Add("onmouseout", "javascript:this.style.cursor='default;")
    End If
    cheers.
    Last edited by jlbantang; Mar 27th, 2011 at 04:52 AM.
    Learn something new every .001 second.

  6. #6
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: navigate pages through datagrid item

    Sounds like you have a solution

    Can you remember to mark your thread as resolved?

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width