quarta-feira, 2 de abril de 2008

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

Esse problema ocorreu comigo no caso de querer utilizar a edição do GridView com o LinqDataSource customizado, ou seja, não utilizei a forma dinâmica pois necessitava um campo de outra entidade.

Enfim.. de acordo com o nosso amigo Scott Guthrie no artigo abaixo a solução é não usar o gridview, mas sim o detailsview para edição e inserção.
http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource-gt-control.aspx

"One feature that will not work with custom shapes/projections, though, is inline editing support.  This is because we are doing a custom projection in our Selecting event, and so the LinqDataSource has no way to safely know how to update an underlying entity object.  If we want to add editing support to the GridView with a custom shaped type, we'd want to either move to using an ObjectDataSource control (where we could supply a custom Update method method to handle the updates), or have the user navigate to a new page when performing updates - and display a DetailsView or FormView control that was bound to a Product entity for editing (and not try and do inline editing with the grid)."

Nenhum comentário: