Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Getting the text of the ButtonColumn

Reply
Thread Tools

Getting the text of the ButtonColumn

 
 
Sathyaish
Guest
Posts: n/a
 
      09-08-2005
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.

 
Reply With Quote
 
 
 
 
john_teague
Guest
Posts: n/a
 
      09-08-2005
Try casting as a LinkButton

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use a value in my dataset as the "Text" of a buttoncolumn? Arch ASP .Net 2 09-15-2009 02:38 AM
Change the Text of ButtonColumn in a DataGrid =?Utf-8?B?QmVu?= ASP .Net 1 01-24-2006 12:42 PM
Getting the text of the ButtonColumn Sathyaish ASP .Net Datagrid Control 0 09-08-2005 07:28 AM
Getting Control ID of buttons in Buttoncolumn in a Datagrid DotNetJunkies User ASP .Net 3 07-07-2004 01:31 PM
Retrieve ButtonColumn Text BK Kim ASP .Net 0 04-06-2004 02:28 AM



Advertisments