I thought they were different objects (related entities)
Nono, very simple. Just one object..
I tried the solution you suggested. I think I'm nearly at the target but I'm still facing two problems:
-
I put a datasource (livePersistence=false) and a save button on the parent aspx page. When clicking the save button the "[i]PerformWork[/i]" method is not executed. I also tried to access the DataSource.UnitOfWork object but it's null. So how can I commit the changes?
"[i]PerformSelect[/i]" is executed properly when loading the page.
-
I put some bound controls on the parent aspx page and some on the sub user controls (ascx). However, the databinding only works on the parent aspx page. Nothing is displayed on the user controls. Below some code lines:
Parent aspx:
<asp:FormView ID="FormView1" runat="server" DataSourceID="employeeDataSource" DefaultMode="Edit" >
<EditItemTemplate>
<asp:TextBox ID="txtTest" runat="server" Text='<%#Eval("Name")%>' />
</EditItemTemplate>
</asp:FormView>
<asp:Button ID="btnSave" runat="server" Text="Speichern" OnClick="btnSave_Click" />
<cc1:LLBLGenProDataSource2 ID="employeeDataSource" runat="server" AdapterTypeName="..." DataContainerType="EntityCollection" EntityFactoryTypeName="..." LivePersistence="false" OnPerformWork="eds_PerformWork" OnPerformSelect="eds_PerformSelect" />
--> Databinding here works good. Value is written to txtTest. However, as explained above I'm not able to commit the changes because eds_PerformWork is never executed.
Parent aspx code-behind:
public LLBLGenProDataSource2 DataSource {
get { return employeeDataSource; } // property to provide DS for sub ascx files..
}
protected void eds_PerformSelect(object sender, PerformSelectEventArgs2 e) {
EmployeeEntity employee = new EmployeeEntity(mId);
mAdapter.FetchEntity(employee);
employeeDataSource.EntityCollection.Add(employee);
}
protected void eds_PerformWork(object sender, PerformWorkEventArgs2 e) {
e.Uow.Commit(mAdapter, true); // this is never executed!!!!
}
Now the user control:
ascx (HTML):
<asp:FormView ID="FormView1" runat="server" DataSourceID="employeeDataSource" >
<ItemTemplate>
<asp:TextBox ID="txtTest2" runat="server" Text='<%#Eval("Name")%>' />
</ItemTemplate>
</asp:FormView>
<cc1:LLBLGenProDataSource2 ID="employeeDataSource" runat="server" AdapterTypeName="..." DataContainerType="EntityCollection" EntityFactoryTypeName="..." LivePersistence="false">
</cc1:LLBLGenProDataSource2>
--> The databinding here doesn't work.. nothing is written to txtTest2. Not even the HTML of the textbox is written to the UI..
ascx (code-behind):
protected void Page_Load(object sender, EventArgs e) {
employeeDataSource = ((IDataSource) Page).DataSource; // get datasource from parent aspx and set it to internal datasource
}
Now I'm really, really curious what the error is!