Dynamic data for template in listBox

2 posts, 0 answers
  1. Taraman
    Taraman avatar
    17 posts
    Member since:
    Aug 2010

    Posted 03 Dec 2010 Link to this post

    Dear Telerik,

    I have created a template inside listBox like your example in the demo: http://demos.telerik.com/aspnet-ajax/listbox/examples/functionality/templates/defaultcs.aspx

    but I don't want to create a static data, so I have created a list like the followin:
          public class Spinning
            public string Title { get; set; }
            public double Price { get; set; }
            public int Quantity { get; set; }
        void RadListBox5_Load()
            List<Spinning> SpinningList = new List<Spinning> 
                new Spinning { Title = "Spinning Reel 1", Price = 99, Quantity = 1 },
                new Spinning { Title = "Spinning Reel 2", Price = 199, Quantity = 1 }
            RadListBox5.DataSource = SpinningList;
    and the the aspx like the following:
    <telerik:RadListBox ID="RadListBox5" runat="server" AllowTransfer="true" 
                AutoPostBackOnTransfer="true" Height="200px" OnTransferred="RadListBox5_Transferred" 
                SelectionMode="Multiple" TransferToID="RadListBox6" Width="215px">
                <ButtonSettings ShowTransferAll="false" VerticalAlign="Middle" />
                    <table cellpadding="1" cellspacing="0" border="0">
                            <td><b><%# DataBinder.Eval(Container, "Attributes['Title']")%></b></td>
                            <td> [Price:</td>
                            <td><%# Convert.ToInt32(DataBinder.Eval(Container, "Attributes['Price']")).ToString("C0") %>]</td>

    the data are not displayed !!!!!
    can you help me on this?

    Mohamed Taraman
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Dec 2010 Link to this post

    Hello Taraman,

     I have modified your code like below .Give a try with it. 

        <%# DataBinder.Eval(Container.DataItem, "Title")%></b></b></td> [Price:
        <%# Convert.ToInt32(DataBinder.Eval(Container.DataItem, "Price")).ToString("C0")%>

Back to Top