can't set text for label within datalist

Discussion in 'ASP .Net' started by Dude, Aug 19, 2003.

  1. Dude

    Dude Guest

    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";
    Dude, Aug 19, 2003
    #1
    1. Advertising

  2. 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:...
    > 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";
    Sonali.NET[MVP], Aug 19, 2003
    #2
    1. Advertising

  3. 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:...
    > 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";
    Sonali.NET[MVP], Aug 19, 2003
    #3
  4. Dude

    Dude Guest

    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:...
    > > 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";

    >
    > --
    Dude, Aug 20, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Label within Datalist

    , May 25, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    6,875
  2. DKode
    Replies:
    0
    Views:
    2,013
    DKode
    Sep 26, 2005
  3. Danny Tuppeny

    Conditional label within DataList?

    Danny Tuppeny, Oct 29, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    684
    Danny Tuppeny
    Oct 30, 2005
  4. Guest
    Replies:
    1
    Views:
    924
    =?Utf-8?B?dGlta2xpbmc=?=
    Jun 5, 2006
  5. Knut Krueger
    Replies:
    8
    Views:
    263
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page