LLBLGenProDataSource - concepts and example please

Posts   
 
    
Kjelli
User
Posts: 27
Joined: 11-May-2006
# Posted on: 11-May-2006 14:23:25   

Hi

Can you please provide sample code for LLBLGenProDataSource (selfservicing) in conjunction with GridView / DetailView / FormView programatically? (custom webparts)

How much work is required when LivePersistence = true? Which parts are automatic during edit and delete?

Currently we have trouble when updating, "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."

Is it required to have

grid.DataKeyNames = new string[] { "CustomerId" };

for llblgen to know the PK? When we enable this line the error goes away, but changed data is lost.

All columns in our GridView are TemplateFields based on classes derived from ITemplate. Will llblgen be able to extract new/edited values from these TemplateFields (ITemplate) or do we need to use IBindableTemplate and implement ExtractValues?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 11-May-2006 18:41:13   

Kjelli wrote:

Hi

Can you please provide sample code for LLBLGenProDataSource (selfservicing) in conjunction with GridView / DetailView / FormView programatically? (custom webparts)

How much work is required when LivePersistence = true? Which parts are automatic during edit and delete?

When LivePersistence is set to true, every change you make to data in your control bound to the datasourcecontrol will be executed on the database directly. So if you click the update link on the gridview control's row to save the changes you made to the row, the changes are executed immediately. This is done for you by the LLBLGenProDataSource control, so no code necessary.

Currently we have trouble when updating, "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."

Is it required to have

grid.DataKeyNames = new string[] { "CustomerId" };

for llblgen to know the PK? When we enable this line the error goes away, but changed data is lost.

When you bind a gridview to a llblgenprodatasource control, it will retrieve the columns from the datasource control and also the PK field(s). This information is required to be able to do updates. I'm surprised your grid doesn't have the PK fields set automatically.

All columns in our GridView are TemplateFields based on classes derived from ITemplate. Will llblgen be able to extract new/edited values from these TemplateFields (ITemplate) or do we need to use IBindableTemplate and implement ExtractValues?

This should be done by the gridiview, as that's the control which calls the datasourcecontrol's ExecuteUpdate, or ExecuteInsert/Select/Delete. So I think you indeed should use a bindabletemplate, although I also have to admit I'm not an expert in gridviewtemplates.

Frans Bouma | Lead developer LLBLGen Pro
Kjelli
User
Posts: 27
Joined: 11-May-2006
# Posted on: 12-May-2006 13:30:09   

We're using Guids as PKs. Could that be the issue?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39619
Joined: 17-Aug-2003
# Posted on: 12-May-2006 13:51:00   

That could be an issue, as you have to set those fields to a value. If you're using SqlServer 2005, you can use the newsequentialid() feature of sqlserver 2005. First make sure the DQE is in Sqlserver2005 mode. You can do this through the config file of your application. (see the beta docs) Then, you have to make the PK guids in the db have as default NEWSEQUENTIALID().

When you now insert a new entity, the PK gets a new sequential GUID, and it's properly read back by llblgen pro. the sequential guid is more efficient as it doesn't fragment the clustered index.

If you're using sqlserver2000, you've to use livepersistence=false, or init an entity's PK field in the entity itself, by overriding OnInitialized() in a partial class.

Frans Bouma | Lead developer LLBLGen Pro