Tuesday, January 03, 2006

ASP.NET 2.0 Profiles - The good and the missing

I recently started using the Profiles feature of ASP.NET 2.0 to store user preferences (search filters, etc.) for a web app. Profiles make it very easy to store and retrieve per-user data without a lot of configuration. They are strongly-typed and way better than using session state or rolling my own database solution.

Immediately after I noticed how great Profiles are, I noticed how obnoxious it was to write the C# code to store and retrieve the profile data. This was the perfect opportunity for me to use a feature I've never used before: Data binding.

I open up the designer for the web control I am working on and I select one of the text boxes that I use to filter a search. In the properties pane, I go to the Data Binding section only to find that binding to a Profile value is not an option. Since I never use data binding, I assumed I just didn't know how to do it properly and began researching. Nowhere did I find anything about binding to Properties. Very disappointing.

What I did find, however, was almost as disappointing. I found huge articles on how to bind data grids and other controls directly to your database. Searching the articles for "validation" returned no results. It seems a bunch of people are fond of allowing users to have a validation-free window directly into their database. I'll refrain from ranting on this particular topic right now, but I wouldn't be surprised if it comes up again in the future.

It's unfortunate that data binding is unavailable in the only instance I'd ever want to use it, but Profiles are still better than session state.

2 Comments:

At 11:09 PM, Blogger ScottGu said...

Hi Greg,

There is a cool ProfileView control out there that you might want to check out: http://weblogs.asp.net/scottgu/archive/2006/01/08/434846.aspx

It allows you to databind your profile and provide easy UI for users to customize their profile properties.

You might also want to check out the new SQL Table Profile Provider: http://weblogs.asp.net/scottgu/archive/2006/01/10/435038.aspx It provides a source code implementation for a profile provider that stores profile data in a table/column layout within a database as an alternative to the built-in profile implementation.

Hope this helps,

Scott

 
At 1:40 AM, Blogger Greg Smalter said...

Scott,

Thanks for the suggestions. It looks like the ProfileView control is great if you plan to have all of your profile fields editable in a single block on a single page. Those who wish to have their profile fields spread throughout their web site will have to stick to manually saving and loading their profile fields.

 

Post a Comment

<< Home