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
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.
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"]
Please specify the id and version fields in the persistent attribute.
[Telerik.OpenAccess.Persistent(IdentityFied="id", VersionField="version"]
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.
Petar
the Telerik team
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"
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.
Petar
the Telerik team