Hi,
I'm using LLBLGenPro 2.6 with Postgres(Npgsql 1.0.0.0) and I have a problem with LLBLGenProDataSourceView2 and the GridView in ASP.Net. I have LivePersistance=True (setting False gives same error), and I get this error when trying to update a row in the grid:
[ORMGeneralOperationException: There are no primary key fields specified in the bound control and/or the bound control didn't specify any primary key fields. Update can't continue.]
SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSourceView2.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +229
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1215
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +837
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +132
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
A bit of digging indeed reveals that the keys parameter has a count=0. In the LLBLGen designer I can see that my entity has IsPK = true on one of the columns (Id), so I would have thought it would pick that up?
Here is the aspx:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="MaintainCourses.aspx.cs" Inherits="MaintainCourses" Title="Untitled Page" %>
<%@ Register Assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" Namespace="SD.LLBLGen.Pro.ORMSupportClasses"
TagPrefix="llblgenpro" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
Category
<asp
ropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp
ropDownList>
<br />
<br />
<div class="todoheader">
Courses
</div>
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True"
AutoGenerateColumns="False"
CssClass="gridview"
AlternatingRowStyle-CssClass="even"
GridLines="None"
DataSourceID="LLBLGenProDataSource1" Width="328px"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowupdated="GridView1_RowUpdated" onrowupdating="GridView1_RowUpdating">
<Columns>
<asp:CommandField ShowSelectButton="True" ShowEditButton="True" />
<asp:BoundField DataField="Id" ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="CategoryId" HeaderText="Category"
SortExpression="CategoryId" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
</Columns>
<AlternatingRowStyle CssClass="even" />
</asp:GridView>
<div class="insertheader">
Add a new course
</div>
<llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource1" runat="server"
AdapterTypeName="em.DatabaseSpecific.DataAccessAdapter, emDBSpecific"
DataContainerType="EntityCollection"
EntityFactoryTypeName="em.FactoryClasses.CourseEntityFactory, em"
onentityupdating="LLBLGenProDataSource1_EntityUpdating1"
onperformselect="LLBLGenProDataSource1_PerformSelect"
onperformwork="LLBLGenProDataSource1_PerformWork">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="CategoryId"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</llblgenpro:LLBLGenProDataSource2>
</asp:Content>