ASP.NET 2.0 Databinding to a Gridview and Saving

Posts   
 
    
timthepig
User
Posts: 2
Joined: 17-Dec-2006
# Posted on: 17-Dec-2006 23:46:28   

Hi,

(Using latest demo trial Dec 6th, 2006)

I've added a LblgenproDatasource to the page at design time. Selected the Datasource of the Gridview to this datasource(and set relevant DataKeyNames on Gridview). Added a seperate Edit/Update column. (Made sure I'm using the latest demo assemblies)

So on editing any row then clicking update, nothing happens.

On the RowUpdating event of the gridview, I have added the following:-

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        LLBLGenProDataSource1.EntityCollection.SaveMulti();
    }

So am I right in assuming that I need to call the SaveMulti method on firing of this gridview event. I'm guessing my issue is to do with State management, as the values of the editing roles seemed to be ignored.

I'm sure I'm missing something glaringly obvious. But I'm looking to do as minimal coding as possible and using the design time features to perform databinding.

Do I have to programatically bind the data at the Page_load event, then declare a new Entity object at the Row_Updating event and perform some iterations?

I simply want to be able to demo a simple gridview with updating functionality, but again using the design time controls and performing as little coding as possible.

Any help would be greatly appreciated!

Cheers

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 18-Dec-2006 07:57:23   

Did you set the LLBLGenProDataSource property LivePersistence to true?

Please post the LLBLGenProDataSource and GridView declarations (the aspx code).

timthepig
User
Posts: 2
Joined: 17-Dec-2006
# Posted on: 18-Dec-2006 09:55:57   

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="SchemaUid"
        DataMember="DefaultView" DataSourceID="LLBLGenProDataSource1" OnRowUpdating="GridView1_RowUpdating1" EnableViewState="False">
        <Columns>
            <asp:BoundField DataField="SchemaUid" HeaderText="SchemaUid" SortExpression="SchemaUid" />
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
            <asp:CommandField ShowEditButton="True" />
        </Columns>
    </asp:GridView>
    <llblgenpro:LLBLGenProDataSource ID="LLBLGenProDataSource1" runat="server" DataContainerType="EntityCollection"
        EntityCollectionTypeName="xxxxx.CollectionClasses.ConceptSchemasCollection, xxxxx"
        >
    </llblgenpro:LLBLGenProDataSource>

I've xxxed the namespace deliberately, this is the .net code. LivePersistance is set to true. I am using SQL Server 2005, and this page exists within a master page.

Cheers

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 18-Dec-2006 15:55:23   

Hello,

you don't need to add

LLBLGenProDataSource1.EntityCollection.SaveMulti();

but you need to add the LivePersistence=true to your llbldatasource like said Walaa :


 <llblgenpro:LLBLGenProDataSource ID="LLBLGenProDataSource1" runat="server" DataContainerType="EntityCollection"         EntityCollectionTypeName="xxxxx.CollectionClasses.ConceptSchemasCollection, xxxxx"
        LivePersistence="true">
</llblgenpro:LLBLGenProDataSource>