Professional Web Applications Themes

can't set text for label within datalist - ASP.NET General

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

  1. #1

    Default can't set text for label within datalist

    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 Guest

  2. #2

    Default Re: can't set text for label within datalist

    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" <com> wrote in message news:google.com... 

    Sonali.NET[MVP] Guest

  3. #3

    Default Re: can't set text for label within datalist

    Ya Marina thanks for pointing
    To the Poster
    Where and which event are you writing the code
    Label lblLabel = ((Label) e.Item.FindControl("LabelGoals")); 
    "Marina" <hotmail.com> wrote in message news:#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]" <com> wrote in message news:%2357Nw$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" <com> wrote in message news:google.com... 

    Sonali.NET[MVP] Guest

  4. #4

    Default Re: can't set text for label within datalist

    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 com> wrote in message news:<#phx.gbl>... 
    > "Marina" <hotmail.com> wrote in message
    > news:#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 com> wrote in message
    > news:%2357Nw$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" <com> wrote in message
    > news:google.com... 
    > error, 
    > "description")%></asp:label></td></tr></table> 
    >
    > --[/ref]
    Dude Guest

Similar Threads

  1. show text on image in datalist
    By mahsa in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: May 3rd, 02:06 PM
  2. Label in a datalist...
    By Onur Bozkurt in forum ASP.NET General
    Replies: 0
    Last Post: August 12th, 01:18 PM
  3. aligning text in a asp label
    By Onur Bozkurt in forum ASP.NET General
    Replies: 0
    Last Post: July 25th, 09:39 AM
  4. Unbound text box as label
    By lars in forum Microsoft Access
    Replies: 3
    Last Post: July 7th, 04:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139