Can set but not read contents of a label!

G

Guest

Hi,
I have a datagrid with a label in the first column (the key basically).
The issue is, that on pressing a standard button outside the datagrid (ie
not one per row) I can SET, but cannot READ the text of the label. I want to
READ the value too!!!

I've copied the basics below, from the contents of the button...

For Each FilmGridItem In dgrdList.Items
Dim lblID As Label = CType(FilmGridItem.Cells(0).Controls(1), Label)
'Dim lblID As Label = CType(FilmGridItem.FindControl("lblTitleID"),
Label)
'(above has same effect)

'I cant read the value on the next line - it is ""
Response.Write(lblID.Text)

'But I can set it!
lblID.Text = "Set the value"
Next

Any ideas?
Thanks.

nb .net 1.1
 
A

Alexey Smirnov

Hi,
I have a datagrid with a label in the first column (the key basically).
The issue is, that on pressing a standard button outside the datagrid (ie
not one per row) I can SET, but cannot READ the text of the label. I want to
READ the value too!!!

I've copied the basics below, from the contents of the button...

For Each FilmGridItem In dgrdList.Items
Dim lblID As Label = CType(FilmGridItem.Cells(0).Controls(1), Label)
'Dim lblID As Label = CType(FilmGridItem.FindControl("lblTitleID"),
Label)
'(above has same effect)

'I cant read the value on the next line - it is ""
Response.Write(lblID.Text)

'But I can set it!
lblID.Text = "Set the value"
Next

Any ideas?
Thanks.

nb .net 1.1

Andy, how did you set the original value of the Label. If it's a
datakey from the database you can use the DataGrid's DataKeys
collection to obtain a key of the row.
 

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

Top