LLBLGenProDataSource w/ GridView - Updates not working

Posts   
 
    
vvillani
User
Posts: 3
Joined: 01-Mar-2009
# Posted on: 20-Mar-2009 21:07:22   

v2.6, C# 3.5 with Sql 2008

I can't get gridview updates and deletes to work. Paging and sorting work flawlessly, but no luck with updates and deletes. I have checked the obvious pitfalls and still can't track down the problem (datakeynames is specified with primary key).

WHAT AM I MISSING HERE? The simplest of examples provided. Any ideas would be appreciated.

<asp:GridView ID="gvItems" runat="server" 
            AllowPaging="true" 
                        AllowSorting="true" 
                        DataKeyNames="itemid"
                        DataSourceID="dsItems"
                        PagerSettings-Mode="NumericFirstLast"
                        PagerSettings-Position="Bottom" 
                        PagerStyle-CssClass="gridViewPager"
                        PageSize="75" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true">
                            <Columns>
                            
                                <asp:BoundField SortExpression="itemid" HeaderText="Item ID " DataField="itemid" Visible="false" ReadOnly="true" />
                                <asp:BoundField SortExpression="itemname" HeaderText="Item Name " DataField="itemname" />
                                <asp:BoundField SortExpression="itemcode" HeaderText="Item Code " DataField="itemcode" />
                                <asp:BoundField SortExpression="itemdesc" HeaderText="Item Description " DataField="itemdesc" />
                                <asp:BoundField SortExpression="qtystart" HeaderText="Starting Qty " DataField="qtystart" />
                                <asp:BoundField SortExpression="qty" HeaderText="Qty On Hand " DataField="qty" />
                                <asp:BoundField SortExpression="qtyalert" HeaderText="Low Status Qty " DataField="qtyalert" />
                            </Columns>
                            <EmptyDataTemplate>
                                No Items Found...
                            </EmptyDataTemplate>                        
                    </asp:CustomGridView>
<llblgenpro:LLBLGenProDataSource ID="dsItems" runat="server" EnablePaging="true" SortingMode="ClientSide" CacheLocation="Session" EntityCollectionTypeName="GreenMonkey.Core.CollectionClasses.ItemCollection, GreenMonkey.Core" DataContainerType="EntityCollection" LivePersistence="true"> </llblgenpro:LLBLGenProDataSource>
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Mar-2009 00:55:15   

Hi there.

DataKeyNames="itemid"

You should use the correct (_CASE SENSITIVE_) field name. In this case, it should be "ItemId" simple_smile

Let us know how it works now.

David Elizondo | LLBLGen Support Team
vvillani
User
Posts: 3
Joined: 01-Mar-2009
# Posted on: 23-Mar-2009 19:29:03   

Thanks for your quick reply David.

Using the case you indicated above did not solve the problem. However, I tried "Itemid" which is the property name of the primary key in the ItemFields class and my deletes starting working. Any thoughts on why updates still don't work?

Also, can you verify that it is indeed the casing found in an entities Field class that should be used?

Appreciate the help!

vvillani
User
Posts: 3
Joined: 01-Mar-2009
# Posted on: 23-Mar-2009 19:43:41   

Got it!

Obviously if the datakeyname had to be cased properly it makes sense for the datafield property of the boundfield to be cased properly. Once I did this the updates worked as well. flushed