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

datalist inside radpanelbar problems

5 Answers 157 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
martin asked on 13 Oct 2008, 11:15 AM

I have a databound radpanel which is working fine. I am trying to populate each panel item with a datalist control, the data of which will be different in each. 

The datasource for the datalist needs to get a value from the slected panel bar to retrieve the correct data.

I have tried adding the datalist to a template which works but all i seem to get is a fully expanded panel and the same data in each of the datalists.

I am using for this, any help greatly appreciated.

5 Answers, 1 is accepted

Sort by
Telerik team
answered on 13 Oct 2008, 11:50 AM
Hello martin,

I guess there's some misunderstanding here. Let me explain.

You cannot collapse a header panel item with a template. Here's a sample:


In this case, you cannot collapse Item1 and Item2.

Here's how the panelbar structure should look as to achieve your goal:

-- (RadpanelItem without text)
-- (RadpanelItem without text)

the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Top achievements
Rank 1
answered on 16 Oct 2008, 05:05 PM

Paul, I'm trying to do something similar.

So, you are saying that instead of having:

<ItemTemplate> template here </ItemTemplate>

We should instead have:

  <Items>   <telerik:RadPanelItem>   <ItemTemplate>   </ItemTemplate>   </telerik:RadPanelItem>   </Items>

If I get you correctly, how exactly can I add say, a new datagrid into each of these item-templates programmatically?

I am databinding the panelbar.

I'm specifically looking for the code to create a new Item, radpanelitem and itemtemplate  in the RadPanelBar1.ItemDataBound event




I will then take the key from the current row, and insert my datagrid into the template.

I do have a simple project with a bare bones setup if would like it, studio 2008 Pro targeting 3.5

I'm actually looking at using the panelbar as an accordion replacement, due to the many problems with using a radgrid inside an accordion.

Let me know if you have any other thoughts.  I'm interested in alternate ways of doing this currently, as the accordion sucks so bad for databound uses.

( EDIT:  Go look for the May patch at

I haven't finished all my work with the gridviews inside the accordion yet, but this seems to have helped a few people with databinding accordions. 

Be prepared to rebuild the entire toolkit on your local box using VS 2005 )

Top achievements
Rank 1
answered on 16 Oct 2008, 06:13 PM

It appears that we are trying to accomplish basically the same thing.  I am trying to replace an accordian with a panelbar where each pane contains a databound grid.  One difference is that my panel bar is not databound, just the grids that are contained within.  Here is my thread asking basically the same question you have (  What I have gotten so far is creating the Items and adding the controls according to what telerik says will work.  You can follow that link above to get the code that I am using, but I am seeing basically the same problems as you.  If you get any further on this, please post your resolution so that I can fix mine as well.

Top achievements
Rank 1
answered on 16 Oct 2008, 08:01 PM
OK, I create a dataset in code, and use it to bind my panelbar AND my datagrids, so don't get confused by my using it twice.

It displays correctly now, but I have no idea about functionality.

I actually need to put some commandbuttons in the grid, but now I need to look up how to create all the grid stuff programmatically...

Here is the aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="AGridTest.aspx.vb" Inherits="POSWizard.AGridTest" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 
<html xmlns="">  
<head runat="server">  
    <title>a grid test</title> 
    <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
            <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="WebBlue" ExpandAnimation-Type="Linear" ExpandMode="SingleExpandedItem" CollapseAnimation-Type="Linear">  
                <CollapseAnimation Type="Linear" Duration="100"></CollapseAnimation> 
                <ExpandAnimation Type="Linear" Duration="100"></ExpandAnimation> 
            <br /> 
            end of panelbar  
            <br /> 

and the .vb:
Imports Telerik.Web.UI  
Partial Public Class AGridTest  
    Inherits System.Web.UI.Page  
    Dim ds As DataSet  
    Private Sub AGridTest_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init  
    End Sub  
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
        If Not IsPostBack Then  
        End If  
    End Sub  
    Sub getdata()  
        Dim table As DataTable = New DataTable("table")  
        Dim column As DataColumn  
        Dim row As DataRow  
        column = New DataColumn()  
        column.DataType = System.Type.GetType("System.Int32")  
        column.ColumnName = "id" 
        column.ReadOnly = True 
        column.Unique = True 
        column = New DataColumn()  
        column.DataType = System.Type.GetType("System.String")  
        column.ColumnName = "Item" 
        column.AutoIncrement = False 
        column.Caption = "Item" 
        column.ReadOnly = False 
        column.Unique = False 
        Dim PrimaryKeyColumns(0) As DataColumn  
        PrimaryKeyColumns(0) = table.Columns("id")  
        table.PrimaryKey = PrimaryKeyColumns 
        ds = New DataSet()  
        Dim i As Integer  
        For i = 0 To 4  
            row = table.NewRow()  
            row("id") = i  
            row("Item") = "This is Item " + i.ToString()  
        Next i  
        RadPanelBar1.DataSource = ds 
        RadPanelBar1.DataFieldID = "id" 
        RadPanelBar1.DataFieldParentID = Nothing 
        RadPanelBar1.DataTextField = "Item" 
        RadPanelBar1.DataValueField = "id" 
        RadPanelBar1.ExpandMode = Telerik.Web.UI.PanelBarExpandMode.SingleExpandedItem  
    End Sub  
    Private Sub RadPanelBar1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadPanelBarEventArgs) Handles RadPanelBar1.ItemDataBound  
        Dim thisItem As RadPanelItem = e.Item  
        Dim thisGrid As RadGrid = MakeMyGrid 
        Dim thisNewItem As New RadPanelItem  
    End Sub  
    Function MakeMyGrid() As RadGrid  
        Dim thisGrid As New RadGrid  
        thisGrid.DataSource = ds 
        ' Must do ALL grid setup in here in some fashion.  
        'thisGrid.Columns.Add(New gridcol  
        Return thisGrid  
    End Function  
End Class 
Top achievements
Rank 1
answered on 23 Oct 2008, 07:17 PM
Lee, Just FYI:

I ended up going back and just using a databound accordion with databound gridviews in the template.

Display was easy enough, but the imagebuttons inside the grid were only firing every OTHER click.  For the failed clicks, they posted back, but no event fired at the server.

After quite a bit of looking around, I found out that the latest version of the ajax tookit does NOT have the latest code.  There is a bugfix on codeplex for the accordion control, which fixed my click/event issues.  From MAY, but it wasn't in the August release.

Not sure if this will help you any or not.

I ended up skipping the panelbar, as it is just too complex to use for databinding purposes for what I needed to get done.
( The panelbar wanted to create a line for the databound row, and a NEW line for the itemtemplate. I need one line total for the "child" rows. )
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Top achievements
Rank 1
Top achievements
Rank 1
Share this question