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

Error bindind to radGrid

6 Answers 108 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Filipe Peixinho
Top achievements
Rank 1
Filipe Peixinho asked on 15 Jun 2009, 10:54 AM
Hi,

i'm using a Open Access Data Source to Bind a RadGrid and i'm having some problems. The grid is correctly populated, but when i try to delete and update rows an exception is thrown:

Changes are not possible if the primary key fields are not visible.
Please specify the id and version fields in the persistent attribute.
[Telerik.OpenAccess.Persistent(IdentityFied="id", VersionField="version"]

I have already tried a lot of diferent aproches and read all of documentary i was able to find in your site. I have notice that already someone post about this problem, but i still can't make it to work.Currently I'm using the version 2009.1.605.1 .

6 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 15 Jun 2009, 01:44 PM
Hello Filipe Peixinho,
indeed our datasource control has some problems with this version of OpenAccess. We have identified and fixed them and the new and improved datasource control will be available with our next internal build. The workaround for deleting as for now is to install a previous version of OpenAccess until a new version is available. We are terribly sorry for the inconvenience this may have caused. Also please account for the fact that the internal builds are not 'production ready'.

Sincerely yours,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
AgJeff
Top achievements
Rank 1
answered on 13 Oct 2010, 02:15 AM
I'm getting this exact same error in the July 2010 release - can you confirm which build (internal or otherwise) has this fixed?
0
AgJeff
Top achievements
Rank 1
answered on 13 Oct 2010, 03:06 AM
I've just tried this with the latest internal build - I've set up a sample that could not be any simpler. I have a database with a single table - create domain model with OA bind to datagrid - display works fine

if you click delete button in table you constantly get this error?!?! The primary key field is visible in the grid, in the domain model any anywhere else you could possibly check it - absolutely no clue what this means

Changes are not possible if the primary key fields are not visible.
Please specify the id and version fields in the persistent attribute.
[Telerik.OpenAccess.Persistent(IdentityFied="id", VersionField="version"]

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Telerik.OpenAccess.Exceptions.UnsupportedException: Changes are not possible if the primary key fields are not visible.
Please specify the id and version fields in the persistent attribute.
[Telerik.OpenAccess.Persistent(IdentityFied="id", VersionField="version"]

0
PetarP
Telerik team
answered on 15 Oct 2010, 05:26 PM
Hello AgJeff,

The problem is that the grid is not passing the id value to the datasource and the reason for that is that you have not specified the "DataKeyNames" property in the design time of the grid. Just write DataKeyNames="CategoryID" (supposing your primary key of the class you are using is CategoryID) in the MasterTableView tag of the RadGrid and everything should work as expected. Here is a sample RadGrid declaration.

<telerik:RadGridID="RadGrid1"runat="server"AllowAutomaticDeletes="True"
        AllowAutomaticInserts="True"AllowAutomaticUpdates="True"
        AllowFilteringByColumn="True"AllowPaging="True"AllowSorting="True"
        AutoGenerateDeleteColumn="True"AutoGenerateEditColumn="True"
        DataSourceID="OpenAccessDataSourceCategories"GridLines="None">
<MasterTableViewAutoGenerateColumns="False"
            DataSourceID="OpenAccessDataSourceCategories"DataKeyNames="CategoryID">
<CommandItemSettingsExportToPdfText="Export to Pdf"></CommandItemSettings>
  
<RowIndicatorColumn>
<HeaderStyleWidth="20px"></HeaderStyle>
</RowIndicatorColumn>
  
<ExpandCollapseColumn>
<HeaderStyleWidth="20px"></HeaderStyle>
</ExpandCollapseColumn>
    <Columns>
        <telerik:GridBoundColumnDataField="CategoryID"DataType="System.Int32"
            HeaderText="CategoryID"SortExpression="CategoryID"UniqueName="CategoryID">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumnDataField="CategoryName"HeaderText="CategoryName"
            SortExpression="CategoryName"UniqueName="CategoryName">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumnDataField="Description"HeaderText="Description"
            SortExpression="Description"UniqueName="Description">
        </telerik:GridBoundColumn>
    </Columns>
</MasterTableView>
    </telerik:RadGrid>

Highlighted is the code that you need to add. 
Please do not hesitate to contact us if you face any further problems.


Kind regards,
Petar
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
AgJeff
Top achievements
Rank 1
answered on 18 Oct 2010, 08:26 PM
I had tried several variants of that before posting - it was an oversight that the property was not set in the example I sent you. So your sample code didn't fix my problem. I finally figured out what is wrong  -  The problem is that this property is case sensitive.

if my ID column in my table is named grpID in the database - setting the datakeys property to grpID will fail. Instead it has to be Grpid. I guess this is a bug in the ORM generator or template. Likewise by primary key/id column in another table is called id but in order to work properly the datakeys propertty has to be set to "Id"
0
PetarP
Telerik team
answered on 19 Oct 2010, 05:00 PM
Hi AgJeff,

I am afraid that I have not received any example from you. The sample I send you implies that the property name of your primary key needs to be used. Please note that the rad grid works with your persistent classes and not your persistent tables. That is why you need to specify the name of the property and not the name of your column.
We are happy that you have managed to resolve your problem. Please feel free to contact us should you face any further difficulties.

Kind regards,
Petar
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Development (API, general questions)
Asked by
Filipe Peixinho
Top achievements
Rank 1
Answers by
PetarP
Telerik team
AgJeff
Top achievements
Rank 1
Share this question
or