Clicking Gridview cell

Discussion in 'ASP .Net' started by Durango2008, May 13, 2008.

  1. Durango2008

    Durango2008 Guest

    Hi, I have a Gridview which contains data derived from DB table within each
    cell.
    The cells are created using ItemTemplate containing Labels used for
    displaying the data. What I would like to know is if there is a way to be
    able to click on the cell to have the data display in another location on
    the page?
    I could not figure out how to do this so I instead made the labels into
    buttons and used the onClick event, which worked fine.
    The problem with buttons is, it does not look good within the Gridview
    cells, I would rather somehow use Labels to achieve this.
    If anyone can help me out I would appreciate it :)
    Thank you very much.
     
    Durango2008, May 13, 2008
    #1
    1. Advertising

  2. Durango2008

    Stan Guest

    On 13 May, 18:33, "Durango2008" <0m> wrote:
    > Hi, I have a Gridview which contains data derived from DB table within each
    > cell.
    > The cells are created using ItemTemplate containing Labels used for
    > displaying the data.  What I would like to know is if there is a way to be
    > able to click on the cell to have the data display in another location on
    > the page?
    > I could not figure out how to do this so I instead made the labels into
    > buttons and used the onClick event, which worked fine.
    > The problem with buttons is, it does not look good within the Gridview
    > cells, I would rather somehow use Labels to achieve this.
    > If anyone can help me out I would appreciate it :)
    > Thank you very much.


    Hi

    If you use link buttons you can format them so they look like ordinary
    text - just set the font-underline property to false and whatever
    color etc you like. In a way you can think of link buttons as labels
    that do postbacks.

    HTH
     
    Stan, May 13, 2008
    #2
    1. Advertising

  3. Durango2008

    Teemu Keiski Guest

    Hi,

    you can add javascript to labels by having code like:

    Label1.Attributes.Add("onclick","alert('Label was clicked')")

    e.g you could wire client-side script to do the stuff, in case that works
    well enough. For server-side clicks to be raised you indeed need a Button or
    a custom control (can implement IButtonControl interface or do it just by
    causing postback from the click)

    Developing a row-clickable GridView gives starters (it' s easy to adapt to
    getting clicks from cells) if you'd want to do it that way
    http://aspadvice.com/blogs/joteke/archive/2006/01/07/14576.aspx

    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net

    "Durango2008" <0m> wrote in message
    news:1ikWj.478$...
    > Hi, I have a Gridview which contains data derived from DB table within
    > each cell.
    > The cells are created using ItemTemplate containing Labels used for
    > displaying the data. What I would like to know is if there is a way to be
    > able to click on the cell to have the data display in another location on
    > the page?
    > I could not figure out how to do this so I instead made the labels into
    > buttons and used the onClick event, which worked fine.
    > The problem with buttons is, it does not look good within the Gridview
    > cells, I would rather somehow use Labels to achieve this.
    > If anyone can help me out I would appreciate it :)
    > Thank you very much.
    >
     
    Teemu Keiski, May 13, 2008
    #3
  4. Durango2008

    Durango2008 Guest

    "Stan" <> wrote in message
    news:..


    Thank you for this suggestion I will look into it ;)
     
    Durango2008, May 14, 2008
    #4
    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. =?Utf-8?B?dGVuemVlbC4=?=

    Fire event when clicking on the specific cell

    =?Utf-8?B?dGVuemVlbC4=?=, Jul 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    430
    =?Utf-8?B?YW5nc3JhbQ==?=
    Jul 28, 2004
  2. Replies:
    2
    Views:
    1,356
  3. misiek
    Replies:
    0
    Views:
    2,300
    misiek
    Feb 20, 2006
  4. Replies:
    1
    Views:
    342
    C. Moya
    Mar 2, 2007
  5. Prasad Peesapati

    Making a cell editable on clicking the cell

    Prasad Peesapati, Feb 3, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    134
    Prasad Peesapati
    Feb 3, 2005
Loading...

Share This Page