Getting the text of the ButtonColumn

Discussion in 'ASP .Net Datagrid Control' started by Sathyaish, Sep 8, 2005.

  1. Sathyaish

    Sathyaish Guest

    How do you get the text of a ButtonColumn control column in a datagrid?
    As an example, I tried this little snippet on a test project, but it
    returns a null string.


    Private Sub dg_ItemCommand(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    dg.ItemCommand
    If Not e.Item Is Nothing Then
    lblMessage.Text = "You clicked " & e.Item.Cells(1).Text &
    "."
    End If
    End Sub


    where the column clicked is of type ButtonColumn and it is the second
    column (index 1) in the row.

    <asp:ButtonColumn DataTextField="Full Name" HeaderText="Full
    Name"></asp:ButtonColumn>

    I also tried:

    Dim lbl As HyperLink = CType(e.Item.Cells(1).Controls(0), HyperLink)
    lblMessage.Text = "You clicked " & lbl.Text & "."

    but it said that the specified cast is not valid.
    Sathyaish, Sep 8, 2005
    #1
    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. BK Kim

    Retrieve ButtonColumn Text

    BK Kim, Apr 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    378
    BK Kim
    Apr 6, 2004
  2. DotNetJunkies User
    Replies:
    3
    Views:
    569
    Eliyahu Goldin
    Jul 7, 2004
  3. Sathyaish

    Getting the text of the ButtonColumn

    Sathyaish, Sep 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    364
    john_teague
    Sep 8, 2005
  4. =?Utf-8?B?QmVu?=

    Change the Text of ButtonColumn in a DataGrid

    =?Utf-8?B?QmVu?=, Jan 23, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    853
    Christopher Reed
    Jan 24, 2006
  5. Arch
    Replies:
    2
    Views:
    294
Loading...

Share This Page