Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > can't set text for label within datalist

Reply
Thread Tools

can't set text for label within datalist

 
 
Dude
Guest
Posts: n/a
 
      08-19-2003
Below is the code - it is finding the control, and there is no error,
just not assigning the text to the label

<aspataList 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>
</aspataList>

Label lblLabel = ((Label) e.Item.FindControl("LabelGoals"));
Trace.Write ("Target Label: " + lblLabel.ClientID);
lblLabel.Text = "dude";
 
Reply With Quote
 
 
 
 
Sonali.NET[MVP]
Guest
Posts: n/a
 
      08-19-2003
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" <> wrote in message news: m...
> Below is the code - it is finding the control, and there is no error,
> just not assigning the text to the label
>
> <aspataList 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>
> </aspataList>
>
> Label lblLabel = ((Label) e.Item.FindControl("LabelGoals"));
> Trace.Write ("Target Label: " + lblLabel.ClientID);
> lblLabel.Text = "dude";


 
Reply With Quote
 
 
 
 
Sonali.NET[MVP]
Guest
Posts: n/a
 
      08-19-2003
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" <> wrote in message news:#...
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]" <> wrote in message news:%2357Nw$...
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" <> wrote in message news: m...
> Below is the code - it is finding the control, and there is no error,
> just not assigning the text to the label
>
> <aspataList 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>
> </aspataList>
>
> Label lblLabel = ((Label) e.Item.FindControl("LabelGoals"));
> Trace.Write ("Target Label: " + lblLabel.ClientID);
> lblLabel.Text = "dude";


 
Reply With Quote
 
Dude
Guest
Posts: n/a
 
      08-20-2003
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 > wrote in message news:<#>...
> 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" <> wrote in message
> news:#...
> 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 > wrote in message
> news:%2357Nw$...
> 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" <> wrote in message
> news: m...
> > Below is the code - it is finding the control, and there is no

> error,
> > just not assigning the text to the label
> >
> > <aspataList 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>
> > </aspataList>
> >
> > Label lblLabel = ((Label) e.Item.FindControl("LabelGoals"));
> > Trace.Write ("Target Label: " + lblLabel.ClientID);
> > lblLabel.Text = "dude";

>
> --

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to programmatically assign text to a label control within a datalist template? ASP .Net 1 06-05-2006 07:37 PM
Conditional label within DataList? Danny Tuppeny ASP .Net 3 10-30-2005 09:04 AM
Access Label control in datagrid within datalist DKode ASP .Net 0 09-26-2005 01:36 PM
Label within Datalist jjack100@gmail.com ASP .Net 8 05-30-2005 07:45 PM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM



Advertisments