LinqDataSource does not support the Select property when the Delete, Insert or Update operations are enabled

為{幸葍}努か 提交于 2019-12-05 05:58:11

In the end I had to select all of the data (using the * option in the DataSource wizard), then remove the columns that I didn't want to display in the GridView. This might be a little inefficient, but it worked.

Just ran into this problem and found a solution and explanation elsewhere.

The Select statement results in an Anonymous type wich may not be mapped when the Delete/Update/Insert statement should be generated by the LinqDataSource. The source Table (linq) is used for generating the metadata for the database operation.

We will have to live whith the small performance loss when needing to retreive all the columns in the data source, but gets some work done behind the scenes. Me like.

And, if you use GridView, you need to specify the DataKeyNames property to the data source's primary key(s).

Crystal clear!? ;)

Sure, the problem is that you must to include the primary key in the data source configuration and then, mark as invisible this primary key.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!