I don't have the northwind database, but if you modify this to use any table with an "ID" primary key and a name column or something similar, you should get the same results:
Here's the grid and LLBLGen data source
<llblgenpro:LLBLGenProDataSource2 ID="fuelTypes" runat="server" AdapterTypeName="Entropy.Envoy.DAL.Generated.DatabaseSpecific.DataAccessAdapter, Entropy.Envoy.DAL.GeneratedDBSpecific"
DataContainerType="EntityCollection" EntityFactoryTypeName="Entropy.Envoy.DAL.Generated.FactoryClasses.FuelTypeEntityFactory, Entropy.Envoy.DAL.Generated"
LivePersistence="false" OnPerformGetDbCount="GetDbCount" OnPerformWork="PerformWork" OnPerformSelect="PerformDBSelect">
</llblgenpro:LLBLGenProDataSource2>
<asp:GridView EnableViewState="false" ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="fuelTypes">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
</Columns>
</asp:GridView>
And heres the code behind
using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entropy.Envoy.DAL.Generated;
using Entropy.Envoy.DAL.Generated.DatabaseSpecific;
using Entropy.Envoy.DAL.Generated.EntityClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
namespace AJAXEnabledWebApplication1
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
fuelTypes.AdapterToUse = GetDAA();
}
private static DataAccessAdapter GetDAA()
{
return
new DataAccessAdapter(
"Stick a Valid Connection String here",
false,
CatalogNameUsage.ForceName,
"");
}
protected void PerformWork(object sender, PerformWorkEventArgs2 e)
{
List<UnitOfWorkElement2> insertItems = e.Uow.GetEntityElementsToInsert();
foreach (UnitOfWorkElement2 item in insertItems)
{
// I do a bit of entity tweaking here, commented out for brevity
}
e.Uow.Commit(GetDAA(), true);
}
protected void PerformDBSelect(object sender, PerformSelectEventArgs2 e)
{
GetDAA().FetchEntityCollection(e.ContainedCollection, e.Filter, 0, e.Sorter, e.PrefetchPath);
}
protected void GetDbCount(object sender, PerformGetDbCountEventArgs2 e)
{
e.DbCount = GetDAA().GetDbCount(e.ContainedCollection, e.Filter);
}
}
}
This code won't work unless I enable ViewState on the Grid. I'm using LLBLGen 2.0 (2.0.7.122).
Thanks