By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,908 Members | 2,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,908 IT Pros & Developers. It's quick & easy.

can't set text for label within datalist

P: n/a
Below is the code - it is finding the control, and there is no error,
just not assigning the text to the label

<asp:DataList id="dlGoals" runat="server"
onEditCommand="myListEditHandler"
onUpdateCommand="myListUpdateHandler"
onCancelCommand="myListCancelHandler"
onDeleteCommand="myListDeleteHandler"
DataKeyField="ID">
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td><asp:ImageButton runat="server" commandname="edit"
ImageUrl="/stap/images/arrow.jpg"
ID="Imagebutton1"></asp:ImageButton></td>
<td colspan="2"><asp:label id="LabelGoals"
runat="server"></asp:label>
<asp:label id="Label1" runat="server"><%# DataBinder.Eval
(Container.DataItem, "description")%></asp:label></td></tr></table>
</ItemTemplate>
</asp:DataList>

Label lblLabel = ((Label) e.Item.FindControl("LabelGoals"));
Trace.Write ("Target Label: " + lblLabel.ClientID);
lblLabel.Text = "dude";
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Write
<asp:label id="Label1" runat="server" text=<%# DataBinder.Eval
(Container.DataItem, "description")%>></asp:label>
Assign value to the Text Property of the Label
"Dude" <ho****@post.com> wrote in message news:1c*************************@posting.google.co m...
Below is the code - it is finding the control, and there is no error,
just not assigning the text to the label

<asp:DataList id="dlGoals" runat="server"
onEditCommand="myListEditHandler"
onUpdateCommand="myListUpdateHandler"
onCancelCommand="myListCancelHandler"
onDeleteCommand="myListDeleteHandler"
DataKeyField="ID">
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td><asp:ImageButton runat="server" commandname="edit"
ImageUrl="/stap/images/arrow.jpg"
ID="Imagebutton1"></asp:ImageButton></td>
<td colspan="2"><asp:label id="LabelGoals"
runat="server"></asp:label>
<asp:label id="Label1" runat="server"><%# DataBinder.Eval
(Container.DataItem, "description")%></asp:label></td></tr></table>
</ItemTemplate>
</asp:DataList>

Label lblLabel = ((Label) e.Item.FindControl("LabelGoals"));
Trace.Write ("Target Label: " + lblLabel.ClientID);
lblLabel.Text = "dude";


Nov 17 '05 #2

P: n/a
Ya Marina thanks for pointing
To the Poster
Where and which event are you writing the code
Label lblLabel = ((Label) e.Item.FindControl("LabelGoals"));
Trace.Write ("Target Label: " + lblLabel.ClientID);
lblLabel.Text = "dude"; "Marina" <zl*******@nospam.hotmail.com> wrote in message news:#Q**************@TK2MSFTNGP12.phx.gbl...
That's not really necessary - I have done it the other way, and it works just fine.

However, I believe the poster was referring to the LabelGoals label, not Label1.
"Sonali.NET[MVP]" <xb********@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...
Write
<asp:label id="Label1" runat="server" text=<%# DataBinder.Eval
(Container.DataItem, "description")%>></asp:label>
Assign value to the Text Property of the Label
"Dude" <ho****@post.com> wrote in message news:1c*************************@posting.google.co m... Below is the code - it is finding the control, and there is no error,
just not assigning the text to the label

<asp:DataList id="dlGoals" runat="server"
onEditCommand="myListEditHandler"
onUpdateCommand="myListUpdateHandler"
onCancelCommand="myListCancelHandler"
onDeleteCommand="myListDeleteHandler"
DataKeyField="ID">
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td><asp:ImageButton runat="server" commandname="edit"
ImageUrl="/stap/images/arrow.jpg"
ID="Imagebutton1"></asp:ImageButton></td>
<td colspan="2"><asp:label id="LabelGoals"
runat="server"></asp:label>
<asp:label id="Label1" runat="server"><%# DataBinder.Eval
(Container.DataItem, "description")%></asp:label></td></tr></table>
</ItemTemplate>
</asp:DataList>

Label lblLabel = ((Label) e.Item.FindControl("LabelGoals"));
Trace.Write ("Target Label: " + lblLabel.ClientID);
lblLabel.Text = "dude";


Nov 17 '05 #3

P: n/a
As included in the code, I need to set the text of the "LabelGoals"
label. Should I need to do it from the init section?

"Sonali.NET[MVP]" <xb so*****@hotmail.com> wrote in message news:<#r**************@TK2MSFTNGP09.phx.gbl>...
Ya Marina thanks for pointing
To the Poster
Where and which event are you writing the code
Label lblLabel = ((Label) e.Item.FindControl("LabelGoals"));
Trace.Write ("Target Label: " + lblLabel.ClientID);
lblLabel.Text = "dude";

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:#Q**************@TK2MSFTNGP12.phx.gbl...
That's not really necessary - I have done it the other way, and it
works just fine.

However, I believe the poster was referring to the LabelGoals label,
not Label1.
"Sonali.NET[MVP]" <xb so*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Write
<asp:label id="Label1" runat="server" text=<%# DataBinder.Eval
(Container.DataItem, "description")%>></asp:label>
Assign value to the Text Property of the Label
"Dude" <ho****@post.com> wrote in message
news:1c*************************@posting.google.co m...
> Below is the code - it is finding the control, and there is no

error,
> just not assigning the text to the label
>
> <asp:DataList id="dlGoals" runat="server"
> onEditCommand="myListEditHandler"
> onUpdateCommand="myListUpdateHandler"
> onCancelCommand="myListCancelHandler"
> onDeleteCommand="myListDeleteHandler"
> DataKeyField="ID">
> <ItemTemplate>
> <table border="0" cellpadding="0" cellspacing="0">
> <tr valign="top">
> <td><asp:ImageButton runat="server" commandname="edit"
> ImageUrl="/stap/images/arrow.jpg"
> ID="Imagebutton1"></asp:ImageButton></td>
> <td colspan="2"><asp:label id="LabelGoals"
> runat="server"></asp:label>
> <asp:label id="Label1" runat="server"><%# DataBinder.Eval
> (Container.DataItem,

"description")%></asp:label></td></tr></table>
> </ItemTemplate>
> </asp:DataList>
>
> Label lblLabel = ((Label) e.Item.FindControl("LabelGoals"));
> Trace.Write ("Target Label: " + lblLabel.ClientID);
> lblLabel.Text = "dude";


--

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.