Retrieve ButtonColumn Text

J

Jason Callas

The first column on my grid is a ButtonColumn type. I want to be able to get
the Text value from withing the ItemCommand event.

I know that e.Item.Cells(0).Text returns an empty string because the cell
has a button control on it. So I thought I would use the control collection
of the cell instead. Because it is a control I should be casting it as a
specific type. Unfortunely this is returning a casting error.

The following code returns and error:

Dim symbol As String
symbol = CType(e.Item.Cells(0).Controls(0),
Web.UI.WebControls.Button).Text


Error = System.InvalidCastException: Specified cast is not valid.


Any thoughts would be appreciated.

- Jason
 

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

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top