This is a migrated thread and some comments may be shown as answers.

Problem with blank templates?

2 Answers 53 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Temp
Top achievements
Rank 1
Temp asked on 28 Jul 2010, 01:51 AM
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 Answers, 1 is accepted

Sort by
0
Temp
Top achievements
Rank 1
answered on 28 Jul 2010, 01:53 AM
I've also tried Container.DataItem in the aspx, which results in the same.
0
Yana
Telerik team
answered on 30 Jul 2010, 11:01 AM
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
Tags
ListBox
Asked by
Temp
Top achievements
Rank 1
Answers by
Temp
Top achievements
Rank 1
Yana
Telerik team
Share this question
or