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

DataBound PanelBar with Template

4 Answers 120 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Aimee Rasmussen
Top achievements
Rank 1
Aimee Rasmussen asked on 05 May 2010, 09:47 PM

After much pain and agony with RadPanelBar and user controls, I'm trying a different approach in using ItemTemplates for the Panel bar items with databinding to a custom object collection.  Now I'm having problems collapsing the different items.  I know that I cannot collapse root items and have tried to follow your examples on how structure my panel bar properly to allow for collapse/expand but I cannot find any documentation in regards to data-bound panel bars..  and I cannot spend anymore time on this one little part of my website.

Here's my markup, designed per http://www.telerik.com/help/aspnet-ajax/panelbar-troubleshooting-root-items-collapse.html:

                <telerik:RadPanelBar ID="radPanelBarAccountList" Runat="server" Height="200%"   
                Width="100%" Skin="Vista" AllowCollapseAllItems="True">  
                    <Items> 
                       <telerik:RadPanelItem runat="server" Text="Replace With Account Name">  
                           <Items> 
                               <telerik:RadPanelItem> 
                                   <ItemTemplate> 
                                       <UC1:AccountInfo ID="AccountInfo1" runat="server" AccountID='<%# DataBinder.Eval(Container.DataItem, "Id") %>' /> 
                                   </ItemTemplate> 
                               </telerik:RadPanelItem> 
                           </Items> 
                       </telerik:RadPanelItem> 
                   </Items> 
                </telerik:RadPanelBar> 

Here's my databinding in code behind:

        'Get collection of accounts  
        Dim accountCollection As Collection(Of FIAccount)  
        Dim accountsPresenter = New AccountsPresenter(New Guid(Session("SubscriberId").ToString), BasePage.GetCultureName.ToString())  
        accountCollection = accountsPresenter.GetAccounts("Actual"False, Account.AccountStatus.All)  
 
        'Bind panel bar  
        With radPanelBarAccountList  
            .DataSource = accountCollection.ToList  
            .DataTextField = "Name" 
            .DataValueField = "Id" 
            .DataBind()  
        End With 

The root items are displaying my account names, as expected, but I cannot expand them to see the user control inside.  I initially defined the markup without any nested items, with the user control defined as an ItemTemplate, and it rendered correclty but I couldn't collapse the items. 

This is kinda crazy!  I can't believe I have to nest so many panel bar items just to get this working properly but if that's how I have to do it, can you give me a code-behind sample on how to bind the individual items so I can display the text value on the child panel items, instead of the root panel item, so I can collapse/expand it?  Or is there a javascript function I can wire up on item click or something?  Like I said, I cannot spend much more time on this and I use this RadPanelBar all over my site!!!

Please Help!!!






4 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 06 May 2010, 03:37 PM
Hi Aimee Rasmussen,

About your problem:
- Looking at your mark-up I noticed that you use "Container.DataItem". I think this is what's causing the problem. Try using just "Container", not "Container.DataItem".

About the inconvenience of nesting items in order to achieve root element's expand/collapse:
- We are working on a new version of the PanelBar and this kind of behavior is in the list of our goals. This will be rolled out in our next major release - sometime around the beginning of July.

I 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.
0
Aimee Rasmussen
Top achievements
Rank 1
answered on 06 May 2010, 05:05 PM

That returns the exception below.. That definately wouldn't work anyway because I'm trying to get at the item's bound Id value..  There has to be some way to bind the PanelBar to the collection and then bind each individual panel item right?? 

Server Error in '/' Application.  
--------------------------------------------------------------------------------  
 
Specified cast is not valid.   
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.   
 
Exception Details: System.InvalidCastException: Specified cast is not valid.  
 
Source Error:   
 
 
Line 32:                 Width="100%" Skin="Vista" AllowCollapseAllItems="True">  
Line 33:                    <ItemTemplate> 
Line 34:                        <UC1:AccountInfo ID="AccountInfo1" runat="server" AccountID='<%# DataBinder.Eval(Container, "Id") %>'/>  
Line 35:                    </ItemTemplate> 
Line 36:                </telerik:RadPanelBar> 
   
 
Source File: C:\Fortress\Visual Studio\MfnWeb\TransactionPages\UserControls\AccountList.ascx    Line: 34   
 
 
0
Aimee Rasmussen
Top achievements
Rank 1
answered on 06 May 2010, 06:28 PM
Is there some documentation on this DataBindings object that would help me out?  Is this what I need to be using?  If so, can you please give me an example of how to use DataBindings in conjunction with user control inside an Item Template please?


<DataBindings>
   
<telerik:RadPanelItemBinding TextField="Category" />
   
<telerik:RadPanelItemBinding FormatString="Made of {0}" TextField="Material" Depth="1" />
</DataBindings>
0
Nikolay Tsenkov
Telerik team
answered on 10 May 2010, 01:19 PM
Hello Aimee Rasmussen,

The template that you provided does what it's supposed to do. I've personally tried it (replacing your UC1:AccountInfo with a simple asp:label). If the problem is not in the template than the next logical place to look is "UC1:AccountInfo".

If you are not able to debug this issue, could you please open a support ticket and provide us with a simple demo reproducing the issue. This will be the best way for us to resolve your problem.

Thanks.


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
Aimee Rasmussen
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Aimee Rasmussen
Top achievements
Rank 1
Share this question
or