This is a migrated thread and some comments may be shown as answers.

Grid automatics update llblgen Entity Problem

1 Answer 37 Views
This is a migrated thread and some comments may be shown as answers.
Hans van Rijnswoud
Top achievements
Rank 2
Hans van Rijnswoud asked on 25 Aug 2009, 01:04 PM

We use the telerik Q 2009 with llblgen pro as #1 O/R mapper and data-access tier generator for .NET.
I create a simple grid directly connected on the entity object via a asp:objectdatasource.

The method select and insert works fine.
But i have a problem with the update method and delete.

For the update and delete method i have the following :
49|error|500|The field 'Id' is read-only and can't be changed.|
If I enable the column Id i don't have any error but the item is not update but created.

I try also to use UpdateCommand Event and UpdateParameters but i received the same error.
Any experience with LLBLgen and Telerik ?

Thanks is advance for your help.


Bellow my code for the Grid :

<telerik:RadGrid ID="GridBranche" runat="server"  
    PagerStyle-AlwaysVisible="True" OnItemDeleted="GridBranche_OnItemDeleted"
    <PagerStyle Mode="Slider" /> 
    <MasterTableView EditMode="InPlace" CommandItemDisplay="Top" HorizontalAlign="NotSet" AutoGenerateColumns="false"  
            <telerik:GridBoundColumn HeaderText="Id" DataField="Id" DataType="System.Int32"  
            SortExpression="Id" UniqueName="BrancheId" ReadOnly="true" /> 
            <telerik:GridBoundColumn HeaderText="Naam" DataField="Name" /> 
            <telerik:GridDropDownColumn HeaderText="Taal" DataField="LanguageId" DataSourceID="_objLanguageSource"  
            DataType="System.Int32" ListValueField="Id" ListTextField="Name" SortExpression="Id" UniqueName="Languages">             
            <telerik:GridDropDownColumn HeaderText="Land" DataField="CountryId" DataSourceID="_objCountrySource"  
            DataType="System.Int32" ListValueField="Id" ListTextField="Name" SortExpression="Id" UniqueName="Country"
            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" HeaderText="Bewerken" /> 
            <telerik:GridButtonColumn ConfirmText="Delete this branche?" ConfirmDialogType="RadWindow" 
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" 
                        UniqueName="DeleteColumn" HeaderText="Wissen" /> 
        <EditFormSettings ColumnNumber="3" CaptionDataField="Name" CaptionFormatString="Aanpassen branche: {0}"
            <FormTableItemStyle Wrap="false" /> 
            <FormMainTableStyle GridLines="None" CellPadding="3" BackColor="White" Width="100%" /> 
            <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" /> 
            <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> 
            <EditColumn ButtonType="ImageButton"  
                InsertText="Insert banner type" UpdateText="Update banner type" UniqueName="EditCommandColumn1" CancelText="Cancel edit"
<asp:ObjectDataSource ID="_objDataSource" runat="server" 
<asp:ObjectDataSource ID="_objLanguageSource" runat="server" SelectMethod="GetLanguages"  
<asp:ObjectDataSource ID="_objCountrySource" runat="server" SelectMethod="GetCountries"  

code for the service layer

public bool  SaveBranche(BranchesEntity entity) 
            if(entity.Id > 0) 
                entity.IsNew = true
            return repository.SaveBranche(entity); 
        public bool UpdateBranche(BranchesEntity entity, int id) 
            entity.IsNew = false
            return repository.SaveBranche(entity); 

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 27 Aug 2009, 12:53 PM
Hi Edwin,

The error you have described is caused by the ObjectDataSource and is not related to RadGrid control (you may observe same behavior with GridView control).
When datasource is updating, it is trying to create a new instance of the entity and set its properties. However as the primary key's property is read only and cannot be modified, the LLBLGen is throwing an exception. In order to workaround this you may try to expose an update method which takes entity's properties' values as parameters and build the entity in the method's body before updating it.

the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Asked by
Hans van Rijnswoud
Top achievements
Rank 2
Answers by
Telerik team
Share this question