Using ASP.NET 3.5 ListView with Subsonic

If you know .NET then you probably know of Scott Gu. Chances are you read his blog and you may have even seen the post entitled “The asp:ListView control (Part 1 – Building a Product Listing Page with Clean CSS UI)”.  This article was pivotal for me in realizing ASP.NET as viable web solution. This is…. outside of the enterprise. As far as I had been concerned .NET suffered from two major flaws which prevented it from being a viable solution for everyday projects.   

1.)  ASP.NET did not have a feature for generating the data access layer and helper methods (prior to 2008).  Without which one must hand program every single property and method.  To my dismay even more 3rd Party Tools (e.g. Codesmith, Subsonic, etc…) were required if one was ever to see his family again.  This gripe, however, was happily satisfied by Subsonic.  Subsonic is what I had envision .NET would be like when I first started migrating from scripting languages.

2.) ASP.NET HTML output was garbage.  When I first saw the HTML rendered by .NET back in 2004 I almost vomited.  To say the least it was simply unacceptable for anyone concerned with SEO and cleanliness.   That is where the ListView and Scott Gu’s article came home.  Listview has all the benefits of .NET, but outputs clean HTML or CSS code. 

So with both of my major gripes solved the next natural step was to unite the two, Subsonic and Listivew together.  That is when I set out to convert Mr. Gu’s LINQ project to Subsonic.  It was a natural starting point and in the beginning it looked like a marriage made in heaven.  It uses SQL 2005 paging techniques so it is very fast.  It is Listview so the output is clean.  Custom paging was a snap and I set out to add sorting and filtering. 

Unfortunately, with all good things there are obstacles.  It does not appear that the built in sorting capabilities of Listview work with Subsonic.  These days I do not have much free time for research so may be awhile until I have a solution.  If you’re interested in using this Listview with Subsonic sample, or if you’re up to the challenge of getting sorting to work, please download the project.  I’d appreciate your comments.  Cheers!

Download Source

Note: The source is VB and requires the Northwind Database.

Quick Tip – Photo Books make great gifts

A friend of mine at MyPublisher introduced me to BookMaker.  Its software that helps you make photobooks from your stash of digital images.  When your book is done you can upload the file to My Publisher and have it professionally printed.  I tried it last year and was completely stunned by the quality.  These are the best gifts ever.  Every holiday I print out about half a dozen for parents and grandparents.  They are alway a huge hit.  The pricing is good and later this year they are coming out with Calendars, Post Cards, and Greeting Cards. 

The current version is 2.3, but I thanks to my pal I have a copy of 3.0.  The new features are really something to look forward to.  I made my sister a calendar from photos of her and her fiance.  You can add photos not only to the top page, but also to the days of the calendar.  The flexibility is truley great.  I can’t wait until I have more time to play with it.

Free Adobe Video Tutorials

I used to spend hours on the old Macromedia website. Every product linked directly to its corresponding developer center. This is an entire section of pages dedicated to helping you use and understand that tool. The Flex product page, for instance, featured several samples and it was actually the flex ecommerce sample that jump started my passion for UI design.



Well, Adobe still has all of this information. It is just a bit less noticeable. You really have to know what your looking for. So here are some really great Adobe links that may bring back memories for those Macromedia junkies.



Adobe Developer Connection : Don’t get lost in the two large sets of menus at the top of the page. The good stuff is in body. Look for "Code & Sample Applications" on the accordion menu.



Site of the Day : Remember the old Macromedia Site of the Day?… still here.



Now, here is something Macromedia did not have. This is the hidden treasure in the whole site.



Free Adobe Video Tutorials : Need I say more?

Microsoft Live – Cash Back

Well, I was pleased to see something exciting come out of the Microsoft Live camp today.

Cash Back! – is a new service linked to your Live.com account that helps you save money by providing… you guessed it “Cash Back” on your purchases.

What’s catch?

Well, like most Microsoft services it seems to have been rushed out the door.  The site is buggy and unintuitive.  I was not even able to sign-up for the service.

Microsoft says “We cannot find your agreement information. Please review and accept agreements and come back to complete your signup.

Needless to say these instructions were completely useless and I am unable to use the service. Bummer, since I really was shopping at the time.

Sadly, it really is unintuitive… very unintuitive.  Just take a peek at the search page…  Please tell me how you can find a product because I am baffled.  It seems that if you do not want select from the predefined product links you are better off searching by store (yeah!).  Now compare this will Google’s Product Search, which display predefined links and an easy to use interface for searching. Moreover, Google’s predefined links are based on popular search so you can see what is HOT!

Needless to say, Live.com’s Cash Back is not the answer to Microsoft’s question “How can I compete against Google?”  The answer is simply… to spend more time creating useful, intuitive services that have quality content.

When will Microsoft learn?

For more information about the service you can read CNet.com’s “Cash Back Coverage”.

Spicy, Hot African Chicken Recipe on RecipeZaar.com

My recipe for African Chicken Stew was recently published on recipezaar.com.

If you’re not familiar with the site I recommend stopping by. They have a nice recipe search and enough users to make it worthwhile. That means tons of good recipes with images and reviews.

Here is a link to the official recipe. Please leave your comments if you find the recipe useful.

Now, some of the users had some questions on the forums. So please check that out as well. Note: The recipe on my blog has already been updated to reflect the discussion on the forums.

Here is the link to the recipe discussion.

Subsonic: SubStage Tips

Using SubStage with Vista

As a user of Vista I have become accustom to installing programs by right click “Run as Administrator”.

When installing SubStage be wary of doing so with Administrative privileges. If you install SubStage with administrative privilege you will only be able to start the application by “right-click”>”Start as Administrator”.

If you encounter an error while opening SubStage simply try it again with Administrative Privileges. It’s likely the program is being blocked by Vista UAC.  I hope this helps.

Once you have it running checkout this SubStage Webcast to help you get around the UI.

Spicy, Hot African Chicken with Spinach

INGREDIENTS

DIRECTIONS

Preparation

  • Rinse off chicken and cut off extra fat. Sprinkle with salt. Set aside.
  • Peel garlic cloves (4-6)
  • Wash and dry spinach

Cooking

  • Heat olive oil and butter in good tall pot, try not to use non stick. Keep heat low so oil does not smoke
  • Add garlic to oil in pan and heat until brown, remove with spoon and set aside (be careful)
  • Add chicken to pan and turn heat to medium
  • Put a good sear on the chicken until it is browned
  • Add half water to pan and deglaze. This will get all the chicken flavor off the bottom of the pan
  • Add the remaining water, bouillon, and pepper to water and bring to a boil. You now have your chicken simmering in a broth
  • Reduce pan liquid by half. Cook until chicken is falling off the bone
  • Add peanut butter, browned garlic, paprika
  • Add spinach and stir until all ingredient have integrated (10 minutes at least)
  • Watch it close so it doesnt burn
  • The stew should be thick when you remove it. If its runny then let it simmer until it thickens.

Subsonic Distinct Join Query VB .NET

Recently I needed to perform a Distinct Join Query using Subsonic. You cannot do this in Subsonic 2.01, but you can with the new Subsonic Beta 2.1. Unfortunately, the samples are all in C# and there is nothing that specifically shows how to do a Distinct. Moreover, they all assume we know how to use the object after it is loaded. However, I see Subsonic a really crucial tool for us guys and gals coming to .NET from Classic ASP. My blog here is really small, but I decided to do my best to fill in some of documentation gaps for using Subsonic with VB.

Distinct Join and Bind to Grid:

                Dim query As New [Select]("Distinct idProduct")
                query.From(Provider.ProductsOrdered.Schema)
                query.InnerJoin(Provider.Order.IdOrderColumn, Provider.ProductsOrdered.IdOrderColumn)

                Dim query2 As New [Select]()
                query2.From(Provider.Product.Schema)
                query2.Where("idProduct").In(query)

                GridView1.DataSource = query2.ExecuteReader()
                GridView1.DataBind()

Distinct Join as Collection and Loop:

            Dim query As New [Select]("Distinct idProduct")
            query.From(Provider.ProductsOrdered.Schema)
            query.InnerJoin(Provider.Order.IdOrderColumn, Provider.ProductsOrdered.IdOrderColumn)
            query.Where("orderDate").IsBetweenAnd(StartTime, EndTime)

            Dim Products As Provider.ProductCollection = New [Select]() _
            .From(Provider.Product.Schema) _
            .Where("idProduct").In(query) _
            .ExecuteAsCollection(Of Provider.ProductCollection)()

            Dim ProductInventory As New Provider.ProductCollection
            For Each Product In ProductInventory

                Dim CurrentStock As Integer = Product.Stock

                If CurrentStock < 1 Then

                    '// Do something

                End If

            Next

If anyone sees anyways to make this code better please comment here. I will post any good suggestions.

Classic ASP Day Dream To .NET Nightmare

I taught myself ASP programming while in Art School for Graphic Design. It was such a breeze. If you got stuck you just Google up a site dedicated to your exact problem. Needless to say, it’s not so easy for VB guys in .NET.

I have been working on my first major project of .NET since first buying into the technology 2 years ago. What really amazed me about .NET was the lack of resources for VB programmers. Everything seemed to be done in C#. Also, how tedious and slow development seemed to be. There was no tool built into Visual Studio that would auto generate my business object! That was crap.

Each .NET promo video that I watched showed someone building a web site in minutes. Unfortunately, the reality is that it “real” web sites take much longer to build in .NET than just scripting them in Classic ASP. The reason being real websites need to be integrated with CSS, designs, and specifications. You can use the membership providers and display controls to make sites quickly, but to make it look like the designer’s layout is another story. I am sure after you build up your base library you can be productive, but starting from scratch was unbearable. Building Objects and Collections was painful (get, set, get, set, get, set, etc…). But the performance benefits of .NET were undeniable. I knew we needed it. So where did that leave me?

One word… Subsonic. This tool really saved me from .NET doom. I watched the video on Getting Started and with a couple hours had my project deadline back on track. It generated all my objects, collections, and everything shows up with intellisense. Even more importantly, I didn’t find any bugs and the Subsonic Forums Community was very helpful.

The only problem is that all of the samples for Subsonic are in C#. Also, you will need to use the Beta version if you require complex queries (e.g. Join Queries). Thankfully, the Beta seems pretty stable and I have not run into any road blocks (crossing my fingers).

Anyway, I started a section on my new blog for Subsonic VB.NET samples.

My first post is about using the New Query Tool 2.3 Beta to make Distinct Join queries. Also, I will show how to execute your query directly into a collection.

Adobe Spry – Vertical Menu Widget

I recently received an inquiry from someone who was using Dreamweaver CS3 to create spry menus. They wanted to know if you can make a Spry Menu expand upward, instead of down or out.

The answer is “Yes”, you can make your sub menus appear above the menu bar by changing the CSS layout.

Submenu placement above parent menu.
To make the menu rise simply add the following CSS Style to SpryMenuBarHorizontal.css:

ul.MenuBarHorizontal ul.MenuBarSubmenuVisible
{

position: absolute;
left: auto;
top: -80px;
}

Be sure to place your menu inside an anchor div, else IE will absolute position from the top of the page and your sub menus will be hidden.

<div id=”inner” style=”position: relative;”>