TypedLists and DataKeyName

Posts   
 
    
stig
User
Posts: 2
Joined: 18-May-2008
# Posted on: 18-May-2008 16:48:26   

Using: .NET 2, LLBLGen v2.5, SQL Server 2005, Self-Servicing

Hi,

I have bound a GridView to a TypedList (which is based on 4 different entities) but I receive an error when defining the 'DataKeyNames' for the GridView. The error is:

"DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'UserName'"

The problem is the DataKeyName has to be a primary key but I don't know how this works when using a TypedList that is based on several entities? - It doesn't seem possible to define a primary key for the TypedList (if this is the solution)



--aspx page--

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                            DataSourceID="PermissionsDataSource" AllowPaging="True" AllowSorting="True" DataKeyNames="Status">

                            <Columns>
                                <asp:BoundField DataField="UserName" HeaderText="Requestor" InsertVisible="False" ReadOnly="True" SortExpression="UserName" />
                            </Columns>
                        </asp:GridView>


  <llblgenpro:LLBLGenProDataSource ID="PermissionsDataSource" runat="server" DataContainerType="TypedList" TypedListTypeName="work.ODS.TypedListClasses.TicketGridTypedList, work.ODS" livepersistence="False" OnPerformSelect="ticketDS_PerformSelect">
  </llblgenpro:LLBLGenProDataSource>



--code-behind--

    protected void ticketDS_PerformSelect(object sender, PerformSelectEventArgs e)
    {
        e.ContainedTypedList.Fill();
    }

Any help would be appreciated.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-May-2008 06:44:02   

TypedList is read-only, so you don't need to define DataKeyName (which is only used to define the PK column, to use its value in updates and deletes).

David Elizondo | LLBLGen Support Team