RadPanelBar within itemtemplate access to Dataform data?

6 posts, 0 answers
  1. Mark
    Mark avatar
    12 posts
    Member since:
    Jul 2015

    Posted 23 Jun Link to this post

    Hi.

    My existing dataform was pulling through the data fields just fine, but I needed to separate them into category’s so decided to use the RadPanelBar.
    But now the fields with in the RadPanelBar wont display.
    It seems silly that you have to rebind this data all over again when the dataform has it already, is there a way to pass through the dataform data into RadPanelBar. After all its sitting in its itemtemplate!

    Many Thanks

    Mark

    <itemtemplate>
     
            <div class="rdfRow">
                <asp:Label ID="p_codeLabel2" runat="server" CssClass="rdfLabel" Text="p_code"></asp:Label>
                <asp:Label ID="p_codeLabel1" runat="server" CssClass="rdfFieldValue" Text='<%# Eval("p_code") %>' />
            </div>
            <div class="rdfRow">
                <asp:Label ID="p_nameLabel2" runat="server" CssClass="rdfLabel" Text="p_name"></asp:Label>
                <asp:Label ID="p_nameLabel1" runat="server" CssClass="rdfFieldValue" Text='<%# Eval("p_name") %>' />
            </div>
     
            <telerik:RadPanelBar RenderMode="Lightweight" runat="server" ID="RadPanelBar2" Width="90%" ExpandMode="MultipleExpandedItems" >
                <Items>
                    <telerik:RadPanelItem Expanded="True" Text="Product key Information">
                        <ContentTemplate>
                            <div class="rdfRow">
                                <asp:Label ID="p_descriptionLabel2" runat="server" CssClass="rdfLabel" Text="p_description"></asp:Label>
                                <asp:Label ID="p_descriptionLabel1" runat="server" CssClass="rdfFieldValue" Text='<%# Eval("p_description") %>' />
                            </div>
     
                            <div class="rdfRow">
                                <asp:Label ID="p_dateLabel2" runat="server" CssClass="rdfLabel" Text="p_date"></asp:Label>
                                <asp:Label ID="p_dateLabel1" runat="server" CssClass="rdfFieldValue" Text='<%# Eval("p_date") %>' />
                            </div>
     
     
                      </ContentTemplate>
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelBar>
    </itemtemplate>
  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 28 Jun Link to this post

    Hello Mark,

    To get the information you need to get reference of the RadDataFormDataItem that contains the PanelBar first. Then you can access the values from it. Check out the modified code below for reference:


    <ItemTemplate>
         
        <asp:Label ID="Label1" runat="server" CssClass="rdfFieldValue" Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>' />
     
        <telerik:RadPanelBar RenderMode="Lightweight" runat="server" ID="RadPanelBar2" Width="90%" ExpandMode="MultipleExpandedItems">
            <Items>
                <telerik:RadPanelItem Expanded="True" Text="Product key Information">
                    <ContentTemplate>
                        <div class="rdfRow">
                            <asp:Label ID="p_descriptionLabel2" runat="server" CssClass="rdfLabel" Text="Description"></asp:Label>
                            <asp:Label ID="p_descriptionLabel1" runat="server" CssClass="rdfFieldValue" Text='<%# DataBinder.Eval((Container.Parent.Parent as RadDataFormDataItem).DataItem, "Description") %>' />
                        </div>
                         
                         
     
                    </ContentTemplate>
                </telerik:RadPanelItem>
            </Items>
        </telerik:RadPanelBar>
    </ItemTemplate>



    Regards,
    Viktor Tachev
    Telerik
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark
    Mark avatar
    12 posts
    Member since:
    Jul 2015

    Posted 28 Jun in reply to Viktor Tachev Link to this post

    Many Thanks Viktor.

    I had to change it to VB but it worked.

    Very happy

    Mark

    <%# DataBinder.Eval(TryCast(Container.Parent.Parent, RadDataFormDataItem).DataItem, "p_description") %>'

  5. Mark
    Mark avatar
    12 posts
    Member since:
    Jul 2015

    Posted 28 Jun Link to this post

    If i am use a RadPanelBar within a Edit template I would use  Bind("p_description"), 

    as well as  <%#  Bind(TryCast(Container.Parent.Parent, RadDataFormDataItem).DataItem, "p_description") %>

    i tried replacing RadDataFormDataItem with RadDataFormEditableItem

    but that wont work.

    Is this possible?.

     

    Many Thanks

     

    Mark

     

    <asp:Label ID="Label4" runat="server" AssociatedControlID="p_descriptionTextBox" CssClass="rdfLabel" Text="p_description"></asp:Label>
                                                                                       <telerik:RadTextBox ID="p_descriptionTextBox" runat="server" RenderMode="Lightweight" Text='<%#  Bind(TryCast(Container.Parent.Parent, RadDataFormEditableItem).DataItem, "p_description") %>' WrapperCssClass="rdfInput" />

  6. Mark
    Mark avatar
    12 posts
    Member since:
    Jul 2015

    Posted 28 Jun Link to this post

    Hi
    From what I can tell there is no way to do a two way bind equivalent  of DataBinder.Eval((Container.Parent.Parent.........
    The best I have been able to do is use DataBinder.Eval within the Dataform  EditTemplate - RadPanelBar and then within the ItemUpdating event find the textbox and then update as necessary.
    Because there is no Bind() on the fields within the RadPanelBar  the ItemUpdating  event won’t see any changes  with ExtractValues.
    Dim editedItem As RadDataFormEditableItem = TryCast(e.DataFormItem, RadDataFormEditableItem)
    editedItem.ExtractValues(newValues)

    Slowly I am finding the more complex I get the more workaround’s I have to do. And the great out of the box functionality that Telerik give, is lost.
    I hope I am wrong, indecently all I wanted was collapsible panels to separate my input controls!!

    Your thought on my approach would be welcome, especially if I am miss something really obvious.

    Many Thanks

    Mark
  7. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 01 Jul Link to this post

    Hi Mark,

    I would like to point out that the scenario you are implementing is a custom one. The controls are placed in a template. Since a template can contain anything there is no way to provide a built-in functionality that would handle all possible scenarios.

    If you would like to use the PanelBar in the EditForm you would need to use custom logic to retrieve the values and update the data source.

    http://docs.telerik.com/devtools/aspnet-ajax/controls/dataform/data-editing/manual-crud-operations

    Regards,
    Viktor Tachev
    Telerik
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017