Problem with blank templates?

3 posts, 0 answers
  1. Temp
    Temp avatar
    55 posts
    Member since:
    May 2007

    Posted 27 Jul 2010 Link to this post

    I have a template defined in the ASPX, and am adding items in code behind from LINQ object.
    The template does not show the attributes. I've read some threads and am not really sure what is possible. Can you please tell me how to do this?


    ASPX Page is like this:

     

     

     

     

    <telerik:RadListBox ID="EmployeesComplianceLevel" runat="server" Width="100%" OnClientSelectedIndexChanged="EmployeesComplianceLevelChanged" style="margin-bottom: 10px">
        <ItemTemplate>
            <font color="black"><%# DataBinder.Eval(Container, "Text")%> </font>
        </ItemTemplate>
    </telerik:RadListBox>

     

    RadListBoxItem listitem1 = new RadListBoxItem();
    listitem1.Value = "1";
    listitem1.Attributes.Add("Text", "one");
    EmployeesComplianceLevel.Items.Add(listitem1);
    RadListBoxItem listitem2 = new RadListBoxItem();
    listitem2.Value = "2";
    listitem2.Attributes.Add("Text", "two");
    EmployeesComplianceLevel.Items.Add(listitem2);
    RadListBoxItem listitem3 = new RadListBoxItem();
    listitem3.Value = "3";
    listitem3.Attributes.Add("Text", "three");
    EmployeesComplianceLevel.Items.Add(listitem3);
    EmployeesComplianceLevel.DataBind();
    foreach (RadListBoxItem item in EmployeesComplianceLevel.Items)
        item.DataBind();


    So I think my listbox would have
    "one"
    "two"
    "three"

    But it is three rows that are blank.

    How can I get the template working with the attributes?
    Screenshot attached of three blank rows:

  2. Temp
    Temp avatar
    55 posts
    Member since:
    May 2007

    Posted 27 Jul 2010 Link to this post

    I've also tried Container.DataItem in the aspx, which results in the same.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 30 Jul 2010 Link to this post

    Hello Michael,

    You should bind the "Text" attribute like this:

    <telerik:RadListBox ID="EmployeesComplianceLevel" runat="server" Width="100%"
        Style="margin-bottom: 10px">
        <ItemTemplate>
            <font color="black">
                <%# DataBinder.Eval(Container, "Attributes[\"Text\"]")%>
            </font>
        </ItemTemplate>
    </telerik:RadListBox>

    Kind regards,
    Yana
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top