Getting the text of the ButtonColumn

S

Sathyaish

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top