Friday 3 April 2009

LinqDatasource not updating when Update Button is clicked in ASP.NET ListView

If you are using a LINQDatasource (or any ASP.NET datasource controls with 2 way databinding) and some of your fields are not updating, then one of the first things you should check is that you are not using Eval, rather than Bind() on your templated fields.

Today, one of my colleagues had issues with both inserting and updating records using a ListView and a LINQ datasource. After a little bit of DK (Divide and Konquer), I eventually found something he had (painfully) overlooked - the Item Template values used Eval (which is fine). However, he had updated the Item template and copied it over to the Edit Item templates and Insert Item templates to save time.

Obviously, Evals are readonly - so the values were never passed into the update of the LINQ datasource.

No comments: