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!
I'd recommend turning off ajax and trying to get the updates working in regular postback mode. Exceptions that are thrown during updates tend to get swallowed by ajax mode unless you are explicitly looking for them.
Also try hooking your data source up to a MS DataView to make sure there's no problems with the linq data source itself.
It's possible that the linq scenario that you're trying isn't supported in 7.3. Support for VS2008 features is something that's being worked on for the 8.1 release. If you find you are running into problems, I'd recommend letting developer support know. They'll be able to pass it on to the development team as a bug to make sure that it works in the new version.
Hi Helen,
I tried your approach and turned off the AJAX mode, didn't help unfortunately.
I found out some things though:- With a normal grid, it works fine. I had some problems at first, but after clearing the page and starting over it all worked well. I used SQL profiler to watch all SQL statements in de database and saw only predictable things.- It seems to be impossible to use both the normal and the infragistics grid on the same datasource. I get exceptions notifying me of duplicate keys while there aren't any; only when both grids are on the same page.- The UltraWebGrid still won't delete. The delete event of the linqdatasource never gets called so I guess that's not strange at all. I think it has probably something to do with the way the LinqDataSource handles a delete. That seems to differ from the way an ObjectDataSource does it for instance. I'll notify developer support and see if they can help me with this, thanks.
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?
I have the same issue using version 8.1.20081.2013, is there a solution?
Paul
I am having the same issue - does anyone have a solution PLEASE!!!
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.
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