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())).CodeI 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>