DataGrid Woes

F

Freddy

I have a datagrid that I created and fill a dataset using a stored proc.
and bind it. The first column( a linkbutton button column) in the DG
contains a number, the second a name. When the user presses the button I
need the number displayed on the link. The number is a field from the
database. I got the code to trap the button press to work, but I cant get
the number displayed.. (vb.net)

Sub Gridclick( byval sender as object, byval e as datagridcommandeventargs)
handles datagrid1.ItemCommand

I've tried different variations of casting such as
CType(e.Item.Cells(0).Controls(0), ButtonColumn) or LinkButton and other
variations
I also tried to use the e.item.cell(0).text and other variations of the
e.item....
I CAN READ the NAME part of the row with e.item.cells(1).text.
WHAT GIVES..?
I tried many different commands till I am frustrated.
A code sample to read the first col link would be great.
Thank You
F
 
E

Elton Wang

Hi Freddy,

If the linkbutton button is in the first column, following code should work:

Dim linkNumber As String = CType(e.Item.Cells(0).Controls(0),
LinkButton).Text

HTH
 

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

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top