LinqDataSource not deleting records

I ran into a small problem using the LinqDataSource as a datasource for a GridView or ListView (the new 3.5 ListView features quite nice functionality, with an insert-capable grid!).

I had set up a datasource with a ListView bound to it which had a button per row to call the ‘Delete’ command. The other commands seemed to work fine (insert, edit) but the delete command didn’t do anything. Just a postback; no exception, no deletion, nothing.

After a lot of debugging, I found out I had set the primary key of my Linq object to be ‘readonly’. I had done this to prevent users from altering the PK and thereby breaking the database. Since the primary key was a generated uniqueidentifier anyway, I didn’t want my users to mess with it.

Anyway; after removing this setting (thus setting it not to be read-only), it suddenly deleted records just as I wanted it to.

The designer’s description for the Read Only setting is: “Controls whether an a set accessor is generated.”. That’s because each column/members get’s its own property with a get/set accessor. I’m not quite sure why this disables the possibility of deleting an object. Perhaps because you can’t create the object without setting it’s primary key, which makes sence. But then again; how is the object populated from the database with the correct private key and why is that method not used to populate it again on postback? Better yet: I would suppose the entire object is stored somewhere in the viewstate between postbacks so the primary key should be in there somewhere, right?

I’m not quite sure about why, but I do know you’d better leave your primary key not be read-only, unless you never want to delete that object.

More Linq to SQL

If you’re into ASP.NET and you want to learn Linq to SQL to provide your user with data from your SQL database, you need Scott Guthrie. And if you don’t know that name yet, you should definitely check out his blog.

For his articles on Linq to SQL, please check out these links:

Free stuff from Microsoft

Surfing around the web I stumbled upon this blogpost from Mohamed Ahmed Meligy writing about free stuff from MS. I thought this would be somekind of action I missed out on and was already too late to sign up for. But no! I tried and this link still takes you to a Microsoft site which requires you to enter your live ID and enter all the profile stuff you’ve probably entered 1000 times already. But after you do that, there are three e-books, one of which is complete, downloadable for free. They’re:

– Introducing Linq
– Introducing ASP.NET AJAX
– Introducing Silverlight 1.0

The Linq one is free in it’s entirety, so no need to buy it anymore. Thanks Microsoft and thanks Mohamed for putting it out there!

My first Linq steps

First of all, I would like to wish you all a happy new year. I know it’s a bit late for that, but I didn’t get (or take…) a chance to post my first blogpost of 2008 earlier. I’m eager to find out what this next year is going to bring us, but I guess I’ll have to wait another 11 1/2 months to be sure 😉

Now, to start off the new year with some tech-talk, I wanted to write a little bit about Linq. Linq is the new way of talking to your database, as far as Microsoft is concerned. It’s kind-off a replacement of the DataSet with DataTables and TableAdapters used in .NET 2.0 projects. Replacement might not be the best way of putting it, because as far as I know, Linq doesn’t really store data the way a DataSet does (keeping DataSets still a very usefull way of storing relational data). Read More

Versioncontrol & Inconsistent filesizes

It’s been a while since my last blogpost. That’s primarily beacuse I’m doing a lot of non-web work at the moment so there’s not too much to blog about.

But now I received a question from a customer which I cannot answer. It seems SharePoint’s file saving functionality is a bit inconsistent when version control is turned on. This is quite easily reproducable in any document library. Take the following steps:

– Create a new document library which has version control turned on
– Upload an empty word document, I didn’t check but I think this will work on any type of document
– Now upload the word document again to overwrite version 1.0 with a new version. U can repeat this to upload some more versions if it doesn’t work the first time.
– Open the documents context menu to view the version history of the document.

If I take above steps, all uploaded versions seem to have a different filesize, even though there’s nothing changed in the file itself. This could be metadata changing, but you would say that information only grows in size, while the file size both grows and shrinks.

If someone knows why this happens, please leave a comment here, I’m eager to find out!

Presence in your own apps!

Bart Wessels’ blog caught my eye once more, blogging about the possibility of adding presence to your own applications. This means you can enable the little popup menu, showing the users’ IM status, availability and contact information, in your own (webbased) applications. Very exiting and I will definitely be trying this soon. I am curious if this will work with MSN Messenger too, since the Microsoft site explicitely talks about Communicator (the business-MSN), but I’ll report back on that.

To download:

Microsoft Presence Sample for AJAX Based Web Client

Microsoft Presence Sample for Smart Client Applications

Microsoft Presence Sample for Web Based Applications

Exchange OWA without Forms Authentication

In many organizations, Outlook Web Access is used to enable employees to view their e-mail and calendar online. In most cases, the enabled access uses Forms Authentication to display a neat Outlook login form in which users may enter their accountname and password to gain access to the web access environment.

SharePoint is able to use this ‘access point’ to display information like e-mail, appointments, etc. on a (my)site. But now the catch… those Outlook Web Parts don’t work with forms authentication enabled. So what we need is a second access point to enable SharePoint to pass on the users’ credentials via Integrated Authentication. Read More

Adding a task for multiple persons

A while ago, a user asked me why he wasn’t able to add a task to a default SharePoint tasklist and assign it to multiple persons. I wasn’t sure about this so I checked myself and indeed I wasn’t able to do this either. For some reason I didn’t really look too hard and didn’t found a solution, but luckily Bart pointed me in the right direction. The (quite easy) solution is to alter the ‘assigned to’ colum via the list properties. There you may set the ‘allow multiple selections’ property to true to enable users to select more than one person or group.

Maybe not that astonishing, but I couldn’t find this one at first so maybe this post turns up in your search results while looking for the same solution 😉

By the way, this solution doesn’t always apply. For instance, in the profile properties of a user there’s a column named ‘Assistant’. This column is also of the ‘Person’ columntype, but you cannot set an ‘allow multiple selections’ property here unfortunately. But hey, who needs multiple assistants if they’ve got SharePoint and Office? 😉