Wierd datalist behavior

S

Steve

Hi,

I have a datalist with some labels embedded inside.

When the page loads, I can see all my labels contain text. on my
datalist_onitemcommand i can even reset their text to something else. What i
can't do is GET the text from the labels i can access. Code is as follows
(no error messages)

Protected Sub test(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataListCommandEventArgs)

If e.Item.ItemType = ListItemType.Item Or _

e.Item.ItemType = ListItemType.AlternatingItem Then

Dim s As String

Dim title As String

Dim loc As String

Dim titlelbl As Label

titlelbl = CType(e.Item.FindControl("MyTitle"), Label) ' Does not give me
the labels text even though the page shows text in the label

title = titlelbl.Text

'If i try something like (titlelbl.text = "Foo") here, it works as expected

End Sub



Thanks

Steve
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top