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

RadPanelItem with RadListBox dynamic binding?

1 Answer 89 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
Brian Mains
Top achievements
Rank 1
Brian Mains asked on 30 Oct 2009, 01:54 PM
Hello,

I tried to adopt what was done in your MVC forum sample project for the RadPanelBar.  What I want to do is add a series of RadPanelItem's that contain a RadListBox control as its interface.  The RadListBox will be data bound.  But I'm getting an error about adding controls after prerender.  Is there something I can do to remedy that, or do the RadPanelItem/RadListBox have to be hard coded in?

My approach was:

<%
if (Model.Groups != null)
{
    foreach (var group in Model.Groups)
    {
        RadListBox box = new RadListBox();
        box.DataSource = group.Items;
        box.DataTextField = "Name";
        box.DataValueField = "Key";

        box.DataBind();

        RadPanelItem item = new RadPanelItem(group.Name);
        item.Controls.Add(box);

        rpbContacts.Items.Add(item);
    }
}
%>

<tel:RadPanelBar ID="rpbContacts" runat="server" />

Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 04 Nov 2009, 12:52 PM
Hello Brian,

To achieve your goal you will need to render the controls with HtmlHelper. Here is attached a simple test project which shows how to use RadHtmlHelper.

Greetings,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Brian Mains
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or