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

RadPanelBar within itemtemplate access to Dataform data?

5 Answers 90 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 23 Jun 2016, 08:20 AM
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>

5 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 28 Jun 2016, 07:25 AM
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
0
Mark
Top achievements
Rank 1
answered on 28 Jun 2016, 09:13 AM

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") %>'

0
Mark
Top achievements
Rank 1
answered on 28 Jun 2016, 10:55 AM

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" />

0
Mark
Top achievements
Rank 1
answered on 28 Jun 2016, 02:09 PM
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
0
Viktor Tachev
Telerik team
answered on 01 Jul 2016, 08:06 AM
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
Tags
DataForm
Asked by
Mark
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Mark
Top achievements
Rank 1
Share this question
or