Get cell string value from datagrid

Discussion in 'ASP .Net' started by Niclas Lindblom, Apr 21, 2004.

  1. Hi,

    I have a datagrid with 2 columns. 1 is a bound column and the other one is a
    button column configured as a link button. When I click the link button, the
    ItemCommand Event fires as it is supposed to. I am able to get the value
    from the first column using

    e.item.cells(0).text

    but I need to get the string value from the link button that was clicked, So
    obviously I thought I would get that from

    e.item.cells(1).text

    But this always returns a empty string....

    Am I doing something wrong, or is there another way I can get this value ?


    Regards

    Niclas
    Niclas Lindblom, Apr 21, 2004
    #1
    1. Advertising

  2. Niclas Lindblom

    alec maclean Guest

    Niclas,

    In your ItemCommand procedure, do this:

    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'Respond to item being clicked
    Dim btn As LinkButton = CType(e.CommandSource, LinkButton)

    Select Case btn.Text
    Case "Details"

    ....etc...

    End Select
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Regards,

    Alec


    "Niclas Lindblom" <> wrote in message
    news:%...
    > Hi,
    >
    > I have a datagrid with 2 columns. 1 is a bound column and the other one is

    a
    > button column configured as a link button. When I click the link button,

    the
    > ItemCommand Event fires as it is supposed to. I am able to get the value
    > from the first column using
    >
    > e.item.cells(0).text
    >
    > but I need to get the string value from the link button that was clicked,

    So
    > obviously I thought I would get that from
    >
    > e.item.cells(1).text
    >
    > But this always returns a empty string....
    >
    > Am I doing something wrong, or is there another way I can get this value ?
    >
    >
    > Regards
    >
    > Niclas
    >
    >
    alec maclean, Apr 21, 2004
    #2
    1. Advertising

  3. Cool, Thanks !

    "alec maclean" <_SPAM> wrote in message
    news:...
    > Niclas,
    >
    > In your ItemCommand procedure, do this:
    >
    > '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > 'Respond to item being clicked
    > Dim btn As LinkButton = CType(e.CommandSource, LinkButton)
    >
    > Select Case btn.Text
    > Case "Details"
    >
    > ...etc...
    >
    > End Select
    > '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    >
    > Regards,
    >
    > Alec
    >
    >
    > "Niclas Lindblom" <> wrote in message
    > news:%...
    >> Hi,
    >>
    >> I have a datagrid with 2 columns. 1 is a bound column and the other one
    >> is

    > a
    >> button column configured as a link button. When I click the link button,

    > the
    >> ItemCommand Event fires as it is supposed to. I am able to get the value
    >> from the first column using
    >>
    >> e.item.cells(0).text
    >>
    >> but I need to get the string value from the link button that was clicked,

    > So
    >> obviously I thought I would get that from
    >>
    >> e.item.cells(1).text
    >>
    >> But this always returns a empty string....
    >>
    >> Am I doing something wrong, or is there another way I can get this value
    >> ?
    >>
    >>
    >> Regards
    >>
    >> Niclas
    >>
    >>

    >
    >
    Niclas Lindblom, Apr 21, 2004
    #3
    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. steve roszko
    Replies:
    1
    Views:
    1,830
    steve
    Aug 12, 2003
  2. =?Utf-8?B?UGF1bA==?=

    datagrid-how to get cell value(hyperlink column)

    =?Utf-8?B?UGF1bA==?=, Oct 12, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    8,865
    =?Utf-8?B?UGF1bA==?=
    Oct 13, 2004
  3. Replies:
    2
    Views:
    1,316
  4. Empire City
    Replies:
    3
    Views:
    390
    Empire City
    Apr 30, 2004
  5. RJ
    Replies:
    1
    Views:
    233
    Eliyahu Goldin
    Feb 17, 2005
Loading...

Share This Page