So over the past few months I have hit so many bugs and errors coding in .NET, that I thought I’d share a some of them that I spent several hours trying to fix, only to realize it was a simple solution. This will be a multi-part series, if all goes to plan.
LINQ Error: “Row not found or changed”. This one took some head scratching. It’s a pretty generic error, and unfortunately the internet wasn’t of great use to finding the answer.
I use timestamp columns in almost every table, since it makes updating values through LINQ a lot easier. (You can use the Attach() method with a timestamp column.)
What was happening is that when I was updating the values in my ListView (i.e. it was in edit mode, and I clicked Update), the timestamp column (named “Version” in my program) was not being sent in the array of values. The quick fix? Add “Version” to the DataKeyNames[] collection specified in the ListView declaration and it works like a charm.
<asp:ListView ID="myListView" runat="server" DataSourceID="myDataSource"
InsertItemPosition="LastItem"
DataKeyNames="Version, DateCreated, CreatedBy">
So now the Attach method was being fed the needed column, as well as a few other house keeping columns I use in my database, and it was updating without any problem!
Print | posted on Wednesday, July 22, 2009 6:04 PM