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

RadPanelItem.DataItem is null on DataBind within FormView

1 Answer 98 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 04 Jan 2013, 09:17 PM

I have a FormView hooked into an ObjectDataSource.  Inside the FormView sits a RadPanelBar.  I have some databound controls within the RadPanelBar and I've had a terrible time getting them to work.

First, I used the suggested method, DataBinder.Eval(FormView1.DataItem, "BillingDate").  This causes the FormView to have an empty oldValues and newValues collection when it updates.  That took me days to figure out.

I then tried an alternative method, strongly typing the DataItem from the container.  

((Wcsr.ProjectBilling.Business.Data.ProjectTask)
                            (Container.DataItem ?? new Wcsr.ProjectBilling.Business.Data.ProjectTask())).Code


I am getting a null DataItem here.  If I use FormView1.DataItem, the oldValues and newValues collections become empty again.  What can I do?

<asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1" DefaultMode="Edit" OnItemUpdated="FormView1_ItemUpdated" OnItemUpdating="FormView1_ItemUpdating">
    <EditItemTemplate>
        <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="Metro" Width="100%">
            <Items>
                <telerik:RadPanelItem runat="server" Expanded="True" PreventCollapse="True" Text="Basic Task Information">
                    <ContentTemplate>
                        <div>
                            <asp:Label ID="Label1" runat="server" CssClass="fieldLabel">Task Code</asp:Label>
                            <%-- For some reason RadPanelItem requires you to do databinding with DataBinder.Eval --%>
                            <asp:TextBox ID="TaskCodeTb" runat="server" MaxLength="20" Text='<%# ((Wcsr.ProjectBilling.Business.Data.ProjectTask)
                            (Container.DataItem ?? new Wcsr.ProjectBilling.Business.Data.ProjectTask())).Code %>'></asp:TextBox>
                        </div>
                        <div>
                            <asp:Label ID="Label4" runat="server" CssClass="fieldLabel">Task Description</asp:Label>
                            <asp:TextBox ID="DescriptionTb" runat="server" MaxLength="250" Rows="3" Text='<%# ((Wcsr.ProjectBilling.Business.Data.ProjectTask)
                            (Container.DataItem ?? new Wcsr.ProjectBilling.Business.Data.ProjectTask())).Description %>' TextMode="MultiLine"></asp:TextBox>
                        </div>
                    </ContentTemplate>
                </telerik:RadPanelItem>
        </telerik:RadPanelBar>
        <asp:LinkButton runat="server" ID="UpdateLb" Text="Update" CommandName="Update"></asp:LinkButton
        <asp:LinkButton runat="server" ID="CancelLb" Text="Cancel" CommandName="Cancel"></asp:LinkButton>
    </EditItemTemplate>
 </asp:FormView>

1 Answer, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 17 Jan 2013, 10:57 AM
Hi Andrew,

I will paste my answer from the ticket here as well in case anyone else encounter the same issue:

I prepared a very simplified runnable project that I believe complies with the scenario that you are trying to achieve. Please download the attached project, run it and let me know if this is the desired effect.

Greetings,
Kate
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
PanelBar
Asked by
Andrew
Top achievements
Rank 1
Answers by
Kate
Telerik team
Share this question
or