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

How to set RadPanelItem.Text property using c# code block?

1 Answer 128 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Syam
Top achievements
Rank 1
Syam asked on 17 Aug 2010, 08:02 AM
how can i set the text property of the RadPanelItem using the inline c# code block? my code line is below. the variables are declared as global "protected string" in the c# code.

 

<telerik:RadPanelBar runat="server" ID="RadPanelBar1" Skin="Web20">
    <Items>
        <telerik:RadPanelItem Text="Quick Links" Expanded="true" PreventCollapse="true">
            <Items>
                <telerik:RadPanelItem Text="<%= textProperty %>" NavigateUrl="<%= urlProperty %>" />
            </Items>
        </telerik:RadPanelItem>
    </Items>
</telerik:RadPanelBar>

 

 

1 Answer, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 17 Aug 2010, 01:26 PM
Hi Syam,

You can use the DataBinder.Eval method to evaluate data from the container the expression is currently in.
Here is the API reference for this method: http://msdn.microsoft.com/en-us/library/4hx47hfe.aspx

Also, here is an alternative way of binding data, which by my opinion is the better (more clear for reading than the inline one):
<telerik:RadPanelBar ID="RadPanelBar1" runat="server" DataSourceID="SqlDataSource1" DataFieldID="id" DataFieldParentID="ParentId">
    <DataBindings>
        <telerik:RadPanelItemBinding Depth="0" TextField="Text" Expanded="true" />
        <telerik:RadPanelItemBinding FormatString="Level 1 > {0}" TextField="Text" Depth="1" />
        <telerik:RadPanelItemBinding FormatString=" Level 2 > {0}" TextField="Text"
            Depth="2" />
    </DataBindings>
</telerik:RadPanelBar>

For additional reference to dataBinding in RadPanelBar, here is a link to the "Overview" article in the DataBinding section of the help pages for this control: http://www.telerik.com/help/aspnet-ajax/panel_databindingoverview.html

Hope this is helpful for you!


Regards,
Nikolay Tsenkov
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
PanelBar
Asked by
Syam
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question
or