Search This Blog

Thursday, October 13, 2005

VS 2005 Web project build

Did you guys ever get a check out error like this one.




You get this error if your code is under source control. VS2005 checks in all folders that are on the files system (with in the project) to source safe. Then it is Source safe that tags it read-only and needing to check out on the next build you do.

The work around is simple, all you need to do is hide the bin folder using Windows explorer. Next time you open the project in VS2005, you will not see the bin folder and VS2005 will not checkin that folder to source safe. Wait, that is not all, however, you will see the bin folder in the Solution Explorer on the next rebuild. Don't panic, VS2005 will not check in the files again. So enjoy web projects now. For more info on this refer to:

http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/VS05WebFiles.asp

Wednesday, October 12, 2005

ObjectDataSource


After blogging yesterday, I couldn't rest until
I found that Microsoft has provided a property
on the object data source to address this situation.

You need to set the DataObjectTypeName to call an Update
or Insert method that accepts an object parameter.






OnUpdated="ObjectDataSource1_Updated" 
DataObjectTypeName="Author" SelectMethod="GetAuthor"
TypeName="Author" UpdateMethod="Save" 
OnUpdating="ObjectDataSource1_Updating"
InsertMethod="Save" 
OnSelecting="ObjectDataSource1_Selecting">




Happy Coding Guys.


Tuesday, October 11, 2005

ObjectDataSource

ObjectDataSource is a cool feature of ASP.NET 2.0. It allows the abstraction of of the data access tier in a multi-tier approach. Data-bound controls can connect to the objectdatasource just like any other datasource. As the object data source is meant to hide the data layer from the presentation tier, you will not find CommandType properties such as the DeleteCommandType or the SelectCommandType. This helps in true abstraction of the data layer from the presentation layer.

Having said all good about ObjectDataSource, it is time disclose a fact. The ObjectDataSource cannot use methods that accept an "Object" as a parameter to Update, Delete or Insert. See the picture below

In the picture, you can see that the Update method is configured to UpdatePerson(Person person). However the runtime will error out with the following message.


"ObjectDataSource 'PersonDataSource' could not find a non-generic method 'UpdatePerson' that has parameters: FirstName, LastName. "

The cheat to this is to write a wrapper method around the UpdatePerson to accept individual attributes and use it. See code snippet below.


Public void UpdatePerson(string FirstName,string LastName)
{
Person p = PersonDAL.GetByName("John");
p.FirstName = FirstName;
p.LastName = LastName;
p.UpdatePerson(p);

}