Hi,
I finally got to playing around a bit with Linq today. I'm using VS2008 (offcourse) and NetAdvantage for ASP.NET 2007 vol 3. For some reason I can't get the ultrawebgrid to update or delete records in the database. The insert statement seems to work fine though.
Here's what I did:- I placed a ultrawebgrid on a new aspx form and chose the LinqDataSource as my data source.- I connected the LinqDataSource to the correct object in my data layer and enabled insert/update/delete features on it The data was displayed correctly, but at first all newly added rows in the grid weren't sent to the database. I noticed no postback (I use an AJAX enabled grid) was issued for new rows. By adding an event handler for the 'UpdateRow' event I was able to trigger a postback (though the event handler itself was empty) and correctly insert a new record into the database.
So far so good, but unfortunately the same trick didn't apply to updating and deleting records. A postback is issued and I can effectively add breakpoints to the UpdateRow and DeleteRow events of the grid, but these updates arent sent to the datasource. I tried adding event handlers for the Updating and Deleting events the DataSource has, but those events aren't fired at all. I also tried calling UpdateDBRow and DeleteDBRow for the correct row passed to the event handlers, but that doesn't do the trick either.
Is there something I'm overlooking? Any help would be appreciated, thanks!
For those who are interested..... this issue appears to be resolved after upgrading to the release version of VS 2008 and .Net 3.5 Service Pack 1. I've tested using both LinqDataSource and EntityDataSource.
Paul
The people at Infragistics have told me there is no fix or workaround, nor is there likely to be anytime soon. Reason is it’s due a bug in the ASP.Net LinqDataSource and the architecture of the webgrid. MS have announced a beta service pack for Visual Studio 2008 and .Net Framework 3.5, I haven’t checked but hopefully it will include a fix for LinqDataSource. You can replicate the issue by binding two standard ASP.Net GridViews to the same LinqDataSource.
For now I’m using the ObjectDataSource to bind to my custom DAL and using Linq to generate quires within it.
VS 2008 SP1: http://www.microsoft.com/downloads/details.aspx?FamilyId=CF99C752-1391-4BC3-BABC-86BC0B9E8E5A&displaylang=en
.Net 3.5 SP1: http://www.microsoft.com/downloads/details.aspx?FamilyId=8C36ACA4-E947-4760-9B05-93CAC04C6F87&displaylang=en
Hope this helps
I am having the same issue - does anyone have a solution PLEASE!!!
I have the same issue using version 8.1.20081.2013, is there a solution?
Hmm... tried some more and found out some interesting things.
The reason why the datasource events didn't trigger was because I hadn't set the DataKeyField to the field which holds my PK. For that reason, apparantly the datasource thought it was told to deleting nothing and did just that fine.
I assumed it would work now, but I was wrong. Now the LinqDataSource actually fires the deleting event, but after that comes up with the exception 'Cannot add an entity with a key that is already in use'. I have really no idea where this is coming from, since I'm not adding but deleting things. Google isn't a great help (not just yet since Linq is still quite fresh) so I'm stuck on this one for now.
But I think you would be glad to hear calling the deleting and updating events works fine. By the way; the above goes for updating too.
By the way: I checked the arguments passed to the delete event of the datasource and they're exactly the same for the ultrawingrid (which doesn't work) and the gridview (which does work). Strange, right?