FormView doesn't save changes...

Posts   
 
    
SanderF
User
Posts: 125
Joined: 11-Dec-2006
# Posted on: 23-Aug-2007 18:03:02   

Hello there

I'm using LLBLGenPro 2.0.0.0 Final I have a user control in which I want to edit data. I have a LLBLGenProDataSource and FormView where I work with :


<llblgenpro:LLBLGenProDataSource ID="LLBLGenProDataSource1" runat="server" DataContainerType="EntityCollection"
    EntityCollectionTypeName="IDB.DigiOffice.DAO.CollectionClasses.PersoonCollection, IDB.DigiOffice"
    CacheLocation="Session" OnPerformSelect="dsrPersoon_PerformSelect" LivePersistence="false" OnPerformWork="dsrPersoon_PerformWork" EnableViewState="true">
</llblgenpro:LLBLGenProDataSource>
<asp:FormView ID="FormView1" runat="server" DataSourceID="dsrPersoon" DataKeyNames="ID" DefaultMode="Edit">
    <EditItemTemplate>
        <table style="width: 100%" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <asp:Label ID="lblZoekNaam" runat="server" Text="Zoeknaam"></asp:Label></td>
                </td>
                <td>
                    <asp:TextBox ID="txtZoekNaam" runat="server" Text='<%# Bind("ZoekNaam") %>'></asp:TextBox>
                </td>
                <td>
                    <asp:Label ID="lblVoornaam" runat="server" Text="Voornaam"></asp:Label></td>
                <td>
                    <asp:TextBox ID="txtVoornaam" runat="server" Text='<%# Bind("Voornaam") %>'></asp:TextBox>
                </td>
                <td>
                    <asp:Label ID="lblGeboorteDatum" runat="server" Text="Geboortedatum"></asp:Label>
                </td>
                <td>
                    <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtGebDatumPartner" Format="dd-MM-yyyy"></ajaxToolkit:CalendarExtender>
                    <asp:TextBox ID="txtGebDatumPartner" runat="server" Text='<%# Bind("PartnerGebDatum", "{0:d}") %>'></asp:TextBox>
                </td>
            </tr>
        </table>
        <asp:button id="UpdateButton" runat="server" causesvalidation="True" commandname="Update" text="Update" />
        <asp:button id="CancelButton" runat="server" causesvalidation="False" commandname="Cancel" text="Cancel" />     
    </EditItemTemplate>
</asp:FormView>

And here is the code behind


protected void dsrPersoon_PerformSelect(object sender, PerformSelectEventArgs e)
{
    PersoonCollection pc = new PersoonCollection();

    PredicateExpression filter = new PredicateExpression();
    filter.Add(PersoonFields.ID == RecID);
    pc.GetMulti(filter);

    dsrPersoon.EntityCollection = pc;
}

protected void dsrPersoon_PerformWork(object sender, PerformWorkEventArgs e)
{
    List<UnitOfWorkElement> uowElement = null;
    PersoonEntity pers = null;

    uowElement = e.Uow.GetEntityElementsToUpdate();

    if (uowElement.Count > 0)
    {
        pers = uowElement[0].Entity as PersoonEntity;

        pers.Save();
    }
}

RecID is a int which is set through a QueryString Parameter

Now my problem is, when I update the record, changes are not saved. For example : I change someone-s Voornaam. When I inspect the UnitOfWork entity, its Voornaam property is not the new value as I entered it in my browser.

Can you please tell me what I'm doing wrong.

Oh, the datasource is a self-servicing one.

Thanks in advance !!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 24-Aug-2007 10:26:35   

And what happens if you just commit the UnitOfWork inside the Perform work as follows?

protected void dsrPersoon_PerformWork(object sender, PerformWorkEventArgs e)
{
    e.Uow.Commit(new Transaction(IsolationLevel.ReadCommitted, "Products"), true);
}
SanderF
User
Posts: 125
Joined: 11-Dec-2006
# Posted on: 24-Aug-2007 11:07:51   

Walaa !

You just saved our day Thanks very much for your assistance !!

Have a nice weekend