S
Steve Hershoff
I'm using VS 2003, and need to extract the text from an asp label in my
code-behind file. The label is part of a DataList's ItemTemplate.
I've noticed that in my ascx file (we're using User Controls here) I can't
set the Text property in the opening tag when writing out the
<asp:Label....</asp:Label> tags. I have to put my text between the opening
and closing tags, like you would with a regular HTML tag.
So this might be the cause of my trouble. What happens in my code-behind
file is I'm trapping the DataBound event on the label's "parent" datalist,
and doing the following:
//from DL_List_DataBound(object sender, DataListItemEventArgs e)
/.....
Label myLabel = (Label) e.Item.FindControl("labelFromASCX_page");
myLabel.Visible = true;
String myString = myLabel.Text;
//........
My problem is, the value of myLabel.Text is always equal to "" even though I
set it in the ascx file. How can I extract the label's text in my
code-behind?
code-behind file. The label is part of a DataList's ItemTemplate.
I've noticed that in my ascx file (we're using User Controls here) I can't
set the Text property in the opening tag when writing out the
<asp:Label....</asp:Label> tags. I have to put my text between the opening
and closing tags, like you would with a regular HTML tag.
So this might be the cause of my trouble. What happens in my code-behind
file is I'm trapping the DataBound event on the label's "parent" datalist,
and doing the following:
//from DL_List_DataBound(object sender, DataListItemEventArgs e)
/.....
Label myLabel = (Label) e.Item.FindControl("labelFromASCX_page");
myLabel.Visible = true;
String myString = myLabel.Text;
//........
My problem is, the value of myLabel.Text is always equal to "" even though I
set it in the ascx file. How can I extract the label's text in my
code-behind?