Accessing asp.net control in RadPanelBar

2 posts, 0 answers
  1. chuck webb
    chuck webb avatar
    1 posts
    Member since:
    Feb 2010

    Posted 28 Feb 2010 Link to this post

    So, here is what I have - I have a master page and then a content page with a RadGrid on it, then in the NestedViewTemplate I have a standard asp:Panel and then in the panel I have a standard asp:DetailsView and then as part of the details view I have a template field which contains the RadPanelBar. First let me tell you what I have working; using the code below I'm able to add the new RadPanelItem and it plugs in the data from the DataRowView, but the way it gets displayed in the RadPanelBar is as a selectable item and you can't select the text. What I want is just plain old text that can be selected like any standard text on a web page. I get what I want if done at design time but of course I want this to happen at run time with the data source for the DetailsView.

        Protected Sub RadPanelbarHistory_OnPanelItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.RadPanelBarEventArgs)  
     
            Dim row As DataRowView = CType(e.Item.DataItem, DataRowView)  
            Dim pnl As RadPanelBar = CType(sender, RadPanelBar)  
     
            pnl.Items(0).Text = "History" 
            pnl.Items(0).Items.Add(New RadPanelItem(row("TicketHistory")))  
     
        End Sub 
     

    So, in the .aspx file I have the following defined. I think what I want to do is write to the label that I have in the ItemTemplate, but I can't get a reference to it.
    <telerik:RadPanelBar ID="RadPanelBarHistory" runat="server" ExpandMode="SingleExpandedItem" 
                    Skin="Web20" AllowCollapseAllItems="True" Width="100%" DataSourceID="ObjectDataSource2" 
                    CausesValidation="False"     OnItemDataBound="RadPanelbarHistory_OnPanelItemDataBound">  
                    <Items> 
                        <telerik:RadPanelItem runat="server" Text="History" Value="Temp">  
                            <Items> 
                                <telerik:RadPanelItem runat="server" Text="templateHolder" Value="templateHolder">  
                                    <ItemTemplate> 
                                        <asp:Label ID="body" runat="server"></asp:Label> 
                                    </ItemTemplate> 
                                </telerik:RadPanelItem> 
                            </Items> 
                        </telerik:RadPanelItem> 
                    </Items> 
                </telerik:RadPanelBar> 

    I have tried almost every example I could find on this board with no luck. Correct me if I'm wrong, but the overall technique is to get reference to the RadPanelBar and then use the FindItemByValue or FindItemByText to get a reference to the RadPanleItem and then do a FindControl to get to the label. So I have tried this technique from multiple RadPanleBar events (OnItemDataBound, OnItemCreated, OnDataBound) as well as from the events from the DetailsView (OnDataBound, OnItemCreated) and I can almost always get to the RadPanelBar, but I can never get a reference to the RadPanelItem using any of the techniques described such as RadPanelBarHistory.FindItemByValue("templateHolder") or RadPanelBarHistory.Items.FindItemByValue("templateHolder") or RadPanelBarHistory.Items(0).Items.FindItemByValue("templateHolder"). It always return nothing. Below is the full listing for the .aspx file.

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" 
        MasterPageFile="~/MasterPage.master" %> 
     
    <%@ Import Namespace="Telerik.Web.UI" %> 
    <%@ MasterType VirtualPath="~/MasterPage.master" %> 
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">  
    </asp:Content> 
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">  
        <asp:Label ID="lblLoc" runat="server" Text="Label"></asp:Label> 
    </asp:Content> 
    <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">  
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Web20" 
            MinDisplayTime="500" InitialDelayTime="200">  
            <img alt="Loading..." src="../Images/ajax-loader.gif" style="border: 0px; margin: 100px 0px 0px 0px;" /> 
        </telerik:RadAjaxLoadingPanel> 
        <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="RadGridQueue">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadGridQueue" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManagerProxy> 
        <telerik:RadGrid ID="RadGridQueue" runat="server" Skin="Web20" GridLines="Vertical" 
            AutoGenerateColumns="False" AllowSorting="True" DataSourceID="ObjectDataSource1" 
            AllowPaging="True" PageSize="100">  
            <PagerStyle AlwaysVisible="True" /> 
            <MasterTableView AutoGenerateColumns="False" DataKeyNames="TicketID" ExpandCollapseColumn-ButtonType="PushButton" 
                DataSourceID="ObjectDataSource1" HierarchyLoadMode="ServerOnDemand">  
                <NestedViewTemplate> 
                    <asp:Panel ID="pnlInnerContainer" runat="server" Visible="true" Style="margin: 5px;">  
                        <asp:Label ID="lblID" runat="server" Text='<%#Eval("TicketID")%>' Visible="false"></asp:Label> 
                        <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="100%" AutoGenerateRows="False" 
                            CellPadding="4" GridLines="Horizontal" ForeColor="#333333" BorderColor="Navy" 
                            BorderStyle="Solid" BorderWidth="1px" DataSourceID="ObjectDataSource2" OnDataBound="DetailsView1_DataBound" 
                            RowStyle-BorderStyle="NotSet" AlternatingRowStyle-BorderStyle="NotSet">  
                            <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" /> 
                            <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" /> 
                            <RowStyle BackColor="#EFF3FB" HorizontalAlign="Left" VerticalAlign="Top" /> 
                            <FieldHeaderStyle Width="140px" BackColor="#DEE8F5" Font-Bold="True" HorizontalAlign="Left" 
                                VerticalAlign="Top" /> 
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Left" VerticalAlign="Top" /> 
                            <Fields> 
                                <asp:BoundField DataField="TicketType" HeaderText="Type" /> 
                                <asp:BoundField DataField="TicketID" HeaderText="Ticket ID" /> 
                                <asp:BoundField DataField="TicketHeadline" HeaderText="Headline" /> 
                                <asp:BoundField DataField="TicketSystem" HeaderText="System" /> 
                                <asp:BoundField DataField="TicketPrimary" HeaderText="Primary" /> 
                                <asp:BoundField DataField="TicketSub" HeaderText="Sub" /> 
                                <asp:BoundField DataField="TicketSeverity" HeaderText="Severity" /> 
                                <asp:BoundField DataField="TicketPriority" HeaderText="Priority" /> 
                                <asp:BoundField DataField="TicketCQState" HeaderText="CQ State" /> 
                                <asp:BoundField DataField="TicketExternalState" HeaderText="External State" /> 
                                <asp:BoundField DataField="TicketKeywords" HeaderText="Keywords" /> 
                                <asp:BoundField DataField="TicketVersion" HeaderText="Version" /> 
                                <asp:BoundField DataField="TicketSubmitDate" HeaderText="Date Submitted" /> 
                                <asp:BoundField DataField="TicketCloseDate" HeaderText="Date Closed" /> 
                                <asp:BoundField DataField="TicketLOE" HeaderText="LOE" /> 
                                <asp:BoundField DataField="TicketRemedyTicketNumber" HeaderText="Remedy Ticket" /> 
                                <asp:BoundField DataField="TicketAssignTo" HeaderText="Assigned To" /> 
                                <asp:BoundField DataField="TicketSubmitter" HeaderText="Submitted By" /> 
                                <asp:BoundField DataField="TicketDescription" HeaderText="Description" /> 
                                <asp:TemplateField HeaderText="History">  
                                    <ItemTemplate> 
                                        <telerik:RadPanelBar ID="RadPanelBarHistory" runat="server" ExpandMode="SingleExpandedItem" 
                                            Skin="Web20" AllowCollapseAllItems="True" Width="100%" DataSourceID="ObjectDataSource2" 
                                            CausesValidation="False" OnItemDataBound="RadPanelbarHistory_OnPanelItemDataBound">  
                                            <Items> 
                                                <telerik:RadPanelItem runat="server" Text="History" Value="Temp">  
                                                    <Items> 
                                                        <telerik:RadPanelItem runat="server" Text="templateHolder" Value="templateHolder">  
                                                            <ItemTemplate> 
                                                                <asp:Label ID="body" runat="server"></asp:Label> 
                                                            </ItemTemplate> 
                                                        </telerik:RadPanelItem> 
                                                    </Items> 
                                                </telerik:RadPanelItem> 
                                            </Items> 
                                        </telerik:RadPanelBar> 
                                    </ItemTemplate> 
                                </asp:TemplateField> 
                                <asp:TemplateField HeaderText="Attachments">  
                                    <ItemTemplate> 
                                        <asp:Label ID="lblAttachments" runat="server" Text="Label"></asp:Label> 
                                    </ItemTemplate> 
                                </asp:TemplateField> 
                            </Fields> 
                            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" VerticalAlign="Top" 
                                HorizontalAlign="Left" /> 
                            <EditRowStyle BackColor="#2461BF" /> 
                            <AlternatingRowStyle BackColor="White" /> 
                        </asp:DetailsView> 
                        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}" 
                            SelectMethod="GetTicketDetails" TypeName="xlsData">  
                            <SelectParameters> 
                                <asp:ControlParameter ControlID="lblID" Name="ID" PropertyName="Text" Type="String" /> 
                            </SelectParameters> 
                        </asp:ObjectDataSource> 
                    </asp:Panel> 
                </NestedViewTemplate> 
                <ExpandCollapseColumn ButtonType="PushButton" Visible="True">  
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridTemplateColumn HeaderText="ID" UniqueName="TicketID" SortExpression="TicketID">  
                        <ItemTemplate> 
                            <asp:Label ID="Label6" runat="server"><%#Eval("TicketID")%></asp:Label> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridTemplateColumn HeaderText="Type" UniqueName="Type" SortExpression="TicketType">  
                        <ItemTemplate> 
                            <asp:Label ID="Label5" runat="server"><%#Eval("TicketType")%></asp:Label> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridTemplateColumn HeaderText="Headline" UniqueName="Headline" SortExpression="TicketHeadline">  
                        <ItemTemplate> 
                            <asp:Label ID="Label1" runat="server"><%#Eval("TicketHeadline")%></asp:Label> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridTemplateColumn HeaderText="Date Submitted" UniqueName="DateSubmitted" 
                        SortExpression="TicketSubmitDate">  
                        <ItemTemplate> 
                            <asp:Label ID="Label3" runat="server"><%#Eval("TicketSubmitDate")%></asp:Label> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridTemplateColumn HeaderText="State" UniqueName="State" SortExpression="TicketExternalState">  
                        <ItemTemplate> 
                            <asp:Label ID="Label2" runat="server"><%#Eval("TicketExternalState")%></asp:Label> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridTemplateColumn HeaderText="Version" UniqueName="Version" SortExpression="TicketVersion">  
                        <ItemTemplate> 
                            <asp:Label ID="Label4" runat="server"><%#Eval("TicketVersion")%></asp:Label> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                </Columns> 
                <NestedViewSettings> 
                    <ParentTableRelation> 
                        <telerik:GridRelationFields DetailKeyField="TicketID" MasterKeyField="TicketID" /> 
                    </ParentTableRelation> 
                </NestedViewSettings> 
                <FooterStyle HorizontalAlign="Center"></FooterStyle> 
            </MasterTableView> 
        </telerik:RadGrid> 
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetAllTickets" 
            TypeName="xlsData" SortParameterName="SortColumns" EnablePaging="True" StartRowIndexParameterName="StartIndex" 
            MaximumRowsParameterName="RowCount" OldValuesParameterFormatString="original_{0}">  
            <SelectParameters> 
                <asp:SessionParameter Name="sys" SessionField="systemName" Type="String" /> 
                <asp:Parameter Name="SortColumns" Type="String" /> 
                <asp:Parameter Name="StartIndex" Type="Int32" /> 
                <asp:Parameter Name="RowCount" Type="Int32" /> 
            </SelectParameters> 
        </asp:ObjectDataSource> 
    </asp:Content> 
     

    Any insight would be greatly appreciated!

    Thanx!
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 04 Mar 2010 Link to this post

    Hello Chuck,

    I cannot run this code without a database, could you please isolate it in a simple project using some dummy database and send it us so we can easily test it? You should open a support ticket in order to be able to attach files. Thanks in advance

    Regards,
    Yana
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top