Navigation

Search

Categories

On this page

Working with the Object Data Source
Moo Cards
ASP .Net Provider Hacks
Getting started with Webparts
VS 2003 Service Pack 1 Released
How to create a MMC SnapIn using .Net
Windows Live Writer (Beta)
A380 in action over Farnborough.
Collection Scott Gu's of ASP .Net posts
Photos from the Farnborough Airshow
Outlook 2007 (Beta 2) Email rendering problem with AVG Anti-virus
Update to the w800i - iTunes Syncher

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 148
This Year: 1
This Month: 0
This Week: 0
Comments: 42

Sign In
Pick a theme:

# Saturday, November 25, 2006
Saturday, November 25, 2006 1:33:32 PM (GMT Standard Time, UTC+00:00) ( .Net Data | .Net Web )

The Object Data Source (ODS) helps you expose your business objects, to provide data to databound controls such as the GridView, DetailsView and many other data bound controls.

Compared to the other data sources like the DataTable and DataSet, the ODS does require some work to achieve the same functionality. The main advantage of the ODS is that it allows you to maintain your layers, without polluting your presentation layer with data code.

To start off,  drag and drop the ODS control to a web form. Set the TypeName property to the business object you want to work with. For example, if we have a BO named Employees in the TimeTracker namespace, this will be TimeTracker.Employee.

Selecting
 A common scenario is to display the a list of records. Say we want to display the list of all employees in a GridView. To retrieve the records, the Employee object needs a GetEmployees static method that will retrieve  all the employees from the DB.  Set the SelectMethod property of the ODS to GetEmployees. Now bind the ODS to the GridView just like any other data source.

At runtime the ODS uses reflection to find the GetEmployees method and invokes it.

Paging and filtering

Filtering Employee objects is as easy as adding a new method to your Employee object. If we want to select Employees by department, the Employee object should have a static method

GetEmployees(string department)

In the properties window of the ODS, add the department parameter to the SelectParameters collection. You can set a default value to it, and this is where things get real easy. You can bind the parameter to a control on your web form ( like a DropDownList) , a Session variable and even a query string parameter.  Adding  filtering functionality is simple as that. You can do the same programmatically by adding Parameters to the SelectParameters collection. Be sure to clear the collection before you add a parameter( or check if the parameter exists).

Paging is where working with the ODS gets a bit complicated. To enable paging ( in conjunction with the GridView) set the EnablePaging property to true. The Employee object too, needs to have methods to support paging.

When paging is enabled, the ODS calls the GetEmployee method with two extra parameters. by default the parameters are startRowIndex and maximumRows. These can be changed by setting the StartRowIndexParameterName and MaximumRowsParameterName properties.

Now we need a GetEmployees method with the signature like
GetEmployees(int startRowIndex,int maxiumRows)
To support filtering it will have to be GetEmployees(string department ,int startRowIndex,int maxiumRows)

The maximumRows parameter, will have the value of how many rows to display per page. This will have the value of the PageSize property of the GridView. The startRowIndex will contain the the index of the current page. This can be the starting row index of the current page of records. See here for more on how to pass these on to an SQL query.

In addition to this the ODS needs another method that is set by the SelectCountMethod property. This is invoked to find out the total number of rows available. So we need another static method in our Employee object. GetEmployeesCount() .If the total number of rows is 100, and you have a page size of 20. The GetEmployees count method should return 100, so that the ODS can tell the GridView, how many pager links to display. I usually return this as an out parameter from the stored procedure that retrieves the paged results.

Inserting, Editing and Deleting

Inserting, editing and deleting is pretty easy. All you will again is to have the appropriate static methods in the Employee object.
AddEmployee(Employee e)
UpdateEmployee(Employee e)
DeleteEmployee(Emplyee e).

Set the InsertMethod , UpdateMethod and DeleteMethod properties accordingly. All these method can be configured with parameters like the SelectMethod. However, setting the DataObjectTypeName property to the Employee object will reduce a lot of the hassle by passing Employee objects to the Add,Update and DeleteMethods.

Comments [0] | | # 
# Saturday, October 07, 2006
Saturday, October 07, 2006 9:58:06 PM (GMT Daylight Time, UTC+01:00) ( Odds & Sods )

http://www.moo.com/

Had mine delivered on Monday and they are pretty cool :) Mini calling cards just the size of a chewing gum. Each card can have a unique photo, in matt print. The printing is high quality.

10 cards free for Flickr Pro users.

Comments [0] | | # 
Saturday, October 07, 2006 9:46:03 PM (GMT Daylight Time, UTC+01:00) ( .Net Web )

 

A few issues to keep in mind when converting a VS 2005 web project to a Web Application project.

http://webproject.scottgu.com/CSharp/Migration2/Mi...

ASP .Net automatically generates a strongly typed Profile class when using Profile Personalization (System.Web.Profiles). This does not happen when using WAP (Web application projects).

There is a free utility to generate the Profile class from the web.config

http://www.gotdotnet.com/workspaces/workspace.aspx...

The default SqlProfilesProvider works by serializing all the profile properties into one column. However, as with all providers this can be changed.

http://www.asp.net/downloads/teamprojects/default.... is a download to a Table profile provider and stored procedure profile provider. These work out of the box, to a profiles table of your own choosing.

Comments [0] | | # 
# Saturday, September 23, 2006
Saturday, September 23, 2006 5:13:58 PM (GMT Daylight Time, UTC+01:00) ( .Net Web )

I was looking into ASP.Net Webparts last week. Here are a few helpful resources.

Sahil Malik introduces Webparts by conducing a walkthrough of creating a qucik and not so dirty CMS (content management system) link 

A good introduction into writing custom editors for web parts by the same author.

A MSDN article giving an overview of the whole framework.

Comments [0] | | # 
# Monday, August 21, 2006
Monday, August 21, 2006 10:13:06 AM (GMT Daylight Time, UTC+01:00) ( .Net General )
Monday, August 21, 2006 9:46:32 AM (GMT Daylight Time, UTC+01:00) ( .Net General | .Net Net | .Net UI )

Found this nice article.

Creating MMC Snapin using C# (Part I)

Requires a the MMC .Net library over at sourceforge.

http://sourceforge.net/projects/mmclibrary/

Comments [0] | | # 
# Wednesday, August 16, 2006
Wednesday, August 16, 2006 12:05:40 PM (GMT Daylight Time, UTC+01:00) ( dasBlog )

Get it while its hot http://windowslivewriter.spaces.live.com/PersonalS...

 Supports pictures, Flickr photos.. image effects... and yes spell checking. Good support for dasBlog.

There's an indepth review here http://blogs.vertigosoftware.com/ericc/archive/200....

The coolest feature is the WYSIWIG editor, which shows exactly how the post will look on the site. It downloads the style from dasBlog.

Lots of pros.

Cons:

1. Can't delete posts.  Can delete posts :)

1. Can't add new categories.

Comments [0] | | # 
Wednesday, August 16, 2006 12:01:31 PM (GMT Daylight Time, UTC+01:00) ( Odds & Sods )

IMG_1124

IMG_1129

Comments [0] | | # 
# Tuesday, August 15, 2006
Tuesday, August 15, 2006 12:15:23 AM (GMT Daylight Time, UTC+01:00) ( .Net Web )
# Tuesday, July 25, 2006
Tuesday, July 25, 2006 10:40:29 AM (GMT Daylight Time, UTC+01:00) ( Odds & Sods )
# Sunday, June 18, 2006
Sunday, June 18, 2006 1:01:55 PM (GMT Daylight Time, UTC+01:00) ( Office 2007 | Windows )

Update 18-12-2006.

This is no longer an issue, with the final release of Outlook 2007. I don't know where it has been fixed, either on AVG or Outlook.

A very dissappointing development is that, Grisoft has decided to discontinue the free edition of AVG.

There is an e-mail rendering problem with Outlook 2007 Beta 2 when used with the Grisoft AVG Outlook plugin.  AVG certifies each incoming email as safe. This causes Outlook not to render the message body. Outgoing messages are blank too.

The fix is to disable the email scanner. I found that the message bodies of my pre and post AVG emails are readable.

AVG says this is about MS not following standards, no comments from the Office team yet. Hope this is fixed soon, as AVG offers an excellent free , light weight AV solution.

Comments [0] | | # 
Sunday, June 18, 2006 11:50:00 AM (GMT Daylight Time, UTC+01:00) ( w800i iTunes Syncher )

Added the option to specify the music folder name on the phone. The folder is now named "music" on some of the new Walkman phones. This makes it possible to use with other mass storage devices.

Please download the latest version .

Installation instructions

For those interested in the source, I''ve created a Gotdotnet workspace.

Comments [0] | | #