March 2007 - Posts

Jeff Atwood on Putting Down the Mouse
29 March 07 10:26 AM | Scott Mitchell

Jeff Atwood has another great blog post, this one about going commando and putting down the mouse. Knowing keyboard shortcuts is a great productivity booster, as the keyboard-to-mouse context switch has high latency. I prefer keeping my hands on the keyboard as much as possible, delegating to the mouse only when necessary. As such, I've setup a variety of keyboard shortcuts in Microsoft Word to perform common actions and am fairly well-versed in the keyboard shortcuts for Visual Studio.

There is one place where I overuse keyboard shortcuts, and that is when I am teaching or training. By habit, when I want to perform some action I use the keyboard shortcut I know, but this doesn't translate well when you are showing a class how to accomplish some task because they only can see your screen on the projector and cannot see the keys you just pressed.

In any event, Jeff's blog entry reminded me of a past experience. There have been many developers I've met over the years who have impressed me in various ways. Here is a story about one of them that is related to Jeff's blog entry...

At the university where I did my undergraduate work, computer science seniors had to take this special class their last two semesters that attempted to mimic real-world software development projects. We'd get assigned to groups and would have to pick a problem from a long list that would involve meeting with real clients (small businesses in the community), crafting requirements, building the app, testing, deploying, and so forth. A pretty neat program.

Anywho, each group would have to give a 15-30 minute presentation at the end of the semester to the faculty and other groups, discussing their progress, challenges encountered, blah blah blah. Many would demo their application. In my junior year I was in the computer lab working on an assignment and in came a group of seniors getting ready to present their senior project. One group member had lugged his desktop computer from home to demo their application. 15 minutes before class was about to start and they were to present, the desktop is plugged in and powered up in order to do a final test run. To his group members horror, the mouse was not working! I don't know if they had it plugged into the wrong port, if it had dropped on the way over, or if it was just an old and unreliable computer or peripheral. Regardless, the group member who brought the desktop machine showed his mettle by shrugging off his group members' panic, going commando and launching the app and running through their presentation entirely from the keyboard!

I didn't know this guy outside of seeing him in the lab a few times over the course of the school year. Never knew his name or saw him again after that day. But I remember his calm in the face of four worried group members and his mastery of the keyboard, and for those reasons I was thoroughly impressed and knew that this would be a developer I'd want on my team.

Filed under:
Office Layout and Space
27 March 07 05:07 PM | Scott Mitchell

Joel Spolsky has an interesting blog entry up about searching for new office space. What's particularly interesting about this post is the contrast between Joel's requirements a the average office space requirements. He is a strong proponent of making the workplace attractive[1] and for his new office space he desires private offices for all employees with ample daylight. The best floorplans to meet such requirements allow for at most 30 feet between the building's outer wall and the core of the building to allow for two rows of offices. However, most office builings in New York have much larger areas between the outer wall and the core to maximize cube farm square footage.

It's interesting to see the tangential challenges that face business owners. And I concur with Joel's opinions on the relationship between attractive and distraction-free workspaces and productivity. I've been working from home for the vast majority of my career, but I did have two office jobs. The first was in a building that had offices and cubicals. When I arrived, the cube farm was full, yet there were open offices, so as luck would have it I ended up with a rather large office with floor to ceiling windows looking out from the 11th story (IIRC). The office could have doubled as a meeting room, as it was huge, and for several months it was all mine!! But as the company grew, they eventually moved three additional developers into the same office.

My only other experience that involved not working from home had be bounce around a few two-person offices. I think I had three different offices in a three month span (moving offices - another productivity drain). Also, constantly moving offices means you don't get to really know your office mate. Joel also espouses the benefits of natural light, and I hearily concur. Working in an office that's cut off from sunlight feels like working in a cave. This is kind of nice if you're a night owl and saunder into work around 4:00 PM, but if you get your most productive work done in the morning or early afternoon hours (like yours truly), then cave-like offices can definitely be a drain on productivity.

So what is Joel to do? How can he balance the real-world topography of office buildings in New York with his lofty requirements? I wonder if he could 'cohabitate' with another company? Joel's crew can have the sunlight offices and the other company can have the dank inner offices or cubes. Or maybe they can pipe in sunlight somehow... solatubes or whatnot.

Filed under:
Four New "Working with Data in ASP.NET 2.0" Tutorials Now Available
27 March 07 09:24 AM | Scott Mitchell

My Working with Data in ASP.NET 2.0 tutorials have been updated to include the four newest tutorials, which look at working with binary data (images, PDFs, MP3s, Word docs, and so on). The four tutorials extend the Categories table in the Northwind database by adding fields that allow users to associate an image and a PDF brochure with each category. The image binary data is stored directly within the Categories table, while the PDF brochure is stored on the web server's file system. Each tutorial builds upon the previous ones, and by the culmination of the fourth tutorial you'll have built screens for inserting, updating, deleting, and displaying binary data.

The four tutorials in this section are:

  • Uploading Files [VB | C#] - illustrates how binary data can be stored on the web server file system or directly within the database, and pros and cons of both approaches. Examples show using the FileUpload control to upload a binary file from the visitor's computer to the web server and how to save it on the web server's file system or directly within the database.
  • Displaying Binary Data in the Data Web Controls [VB | C#] - looks at how to display binary data within the GridView. For images, this may mean showing the image within each GridView row. For other file types, this likely means a link that, when clicked, takes the user to the binary data or prompts them to save it on their computer. Again, examples of binary files stored on the file system and within the database are provided.
  • Including a File Upload Option When Adding a New Record [VB | C#] - learn how to augment the DetailsView to include a FileUpload control, allowing a visitor to add a new record to the database while uploading associated binary data.
  • Updating and Deleting Existing Binary Data [VB | C#] - once binary data has been associated with a database record, we may need to update or delete the binary data or delete the record in its entirety.

Like the previous tutorials in the series, all tutorials are available in C# and VB, include the complete code download as a self-extracting ZIP, and are available in PDF format.

Happy Programming!

Filed under:
Inserting through the GridView's Footer Row - Easy Unless There are No Records Bound to the Grid!
16 March 07 02:55 PM | Scott Mitchell

As I mentioned in an earlier blog post this month, three new data tutorials were added to my Working with Data in ASP.NET 2.0 tutorial series. One of these new tutorials looked at how to use the GridView's footer row as an inserting interface (see Inserting a New Record from the GridView's Footer [VB | C#]). The “footer as inserting interface” approach works well enough if there are records bound to the GridView. However, if you are working with a GridView that has no data associated with it, the footer row doesn't appear. In ASP.NET 1.x this wasn't an issue because regardless of whether there were any records in the DataGrid's data source, the header and footer were still displayed. It was the page developer's responsibility to check if there were no data records bound to the DataGrid and, if so, to hide the grid and display an appropriate message. In the case of using the footer to insert, however, we would leave the DataGrid visible so that the footer row was still present to allow the user to add the first record to the grid.

The GridView in ASP.NET 2.0 works a bit differently. If there are no records in the GridView's data source, it does not display its header or footer. If its EmptyDataText or EmptyDataTemplate properties are set, it will show that, otherwise the GridView emits no markup.

So, if you have an inserting interface in the GridView's footer, but there are no records in the underlying table, the footer will not display! Eep. What to do?

One option is to use the EmptyDataTemplate property. Drop a DetailsView in there, bind it to the same data source control as the GridView, check the “Enable Inserting” option from its smart tag and set its DefaultMode property to Insert. This will present the user with an inserting interface when there are no records in the table. Once they add a new record, the GridView will display its new, single record and future records can be added through the footer row.

If you use the DetailsView in the EmptyDataTemplate option and bind it to the same ObjectDataSource as used by the GridView with the code presented in the tutorial, you'll need to make one minor code modification. The ObjectDataSource has an event handler for its Inserting event. There is picks out the values from the footer and uses those values to populate its parameters. When inserting from the DetailsView, however, we can use two-way databinding instead (i.e., adding <%# Bind(”ColumnName”) %> to the properties of the Web controls in the DetailsView's InsertItemTemplates). Consequently, you'll need to bypass reading in the GridView's footer row values when inserting from the DetailsView, which can be accomplished with the following conditional statement:

1 // Only performt he following logic when inserting through the footer

2 if (Products.Rows.Count == 0)

3 // We are inserting through the DetailsView in the EmptyDataTemplate

4 return;

I've got a working example you can download to test this out. It's a stripped-down version of the download from the tutorial. I've manually deleted all of the rows from the Products table and added a DetailsView to the GridView's EmptyDataTemplate. Moreover, I've bound this DetailsView to the same ObjectDataSource as used by the GridView, added the above conditional statement to the ObjectDataSource's Inserting event handler, and added the markup to implement two-way databinding on the DetailsView. You can download this example from:

Hope this helps and, as always, Happy Programming!

Filed under:
GotDotNet? Not Anymore, You Don't
15 March 07 10:18 AM | Scott Mitchell

Microsoft's web property GotDotNet will be completely shut down and phased out of existence by June 19, 2007. From the GotDotNet homepage:

Microsoft will be phasing out the GotDotNet site by July 2007.

Microsoft will phase out all GotDotNet functionality by July 2007. We will phase out features according to the schedule below. During the phase-out we will ensure that requests for features or pages that are no longer available will render enough information for you to understand what has changed. If you have any questions please don’t hesitate to contact the GotDotNet Support team.

We are phasing out GotDotNet for the following reasons:

  • Microsoft wants to eliminate redundant functionality between GotDotNet and other community resources provided by Microsoft
  • Traffic and usage of GotDotNet features has significantly decreased over the last six months
  • Microsoft wants to reinvest the resources currently used for GotDotNet in new and better community features for our customers

  • Phase Out Schedule
    The GotDotNet phase out will be carried out in phases according the following timetable:

    Target Date Areas to be Closed
    February 20 Partners, Resource Center, Microsoft Tools
    March 20 Private workspaces, Team pages, Message Boards
    April 24 GDN CodeGallery (projected date)
    May 22 GDN User Samples (projected date)
    June 19 GDN Workspaces (projected date)

    I understand how Microsoft doesn't want to dedicate any resources to a “dead site,” but why kill the site altogether? Couldn't they just stop new workspaces from being opened, stop new messageboard posts, stop new user samples from being submitted, and so on, but leave the existing pages up and available? There are countless messageboard posts, user samples, articles, and other valuable content that Microsoft is just throwing away. (The messageboard at the skmMenu workspace, for example, has over 1,000 messageboard posts that will evaporate come June 19.)

    Back in the COM days (and now in the Web Services sphere), developers harped on public interfaces exposed by a COM component or a Web service endpoint, and how these interfaces represented a contract that should never be broken. Doesn't a URL constitute a public interface into a web application? Once a URL is public, shouldn't that URL always work? My opinion is that it should. For example, I have DataGrid FAQs up at, but since the advent of ASP.NET 2.0 the DataGrid has been relegated to the dustbin of web technology. Sure, there are still people doing ASP.NET 1.x (including yours truly), but as time marches on, this will become less important. Yet I plan to keep these FAQs there in perpetuity because once a URL is public and has been put out there for the world to consume, it is rude (and, dare I say, wrong) to remove it.

    Hopefully Microsoft will decide to let GDN live on, if just as its existing content. Failure to do so not only removes useful content from the Internet, but also sends a rather innocuous message to users of CodePlex, Microsoft's GDN successor: “One day we might decide to nuke this site and your projects, messages, and contributions.”

    April's Toolbox Column Now Available Online
    15 March 07 09:19 AM | Scott Mitchell

    My Toolbox column in the April 2007 issue of MSDN Magazine is now avaiable online. The April issue examines three products:

    • WiXAware - a program for graphically creating and managing WiX installation files.
    • Apose.Slides for .NET - programmatically create and edit PowerPoint presentations.
    • Subversion - a popular, open-source source control product.

    This month's issue reviewed SQL Hacks, by Andrew Cumming and Gordon Russell. Here is an excerpt from the review:

    Most books on SQL focus on its syntax and semantics, specifying the structure of the SELECT statement, how the GROUP BY clause can be used, and so forth. While such information is helpful for beginners, seasoned database professionals are more interested in scenario-based learning. They want to read about queries and techniques that can help them tackle their difficult problems. What queries can you use to identify overlapping ranges in data? How do you create and maintain an audit table, or compare and synchronize tables? If this is the kind of information you are searching for, check out SQL Hacks, written by Andrew Cumming and Gordon Russell and published by O'Reilly.

    As always, if you have any suggestions for products or books to review for the Toolbox column, please send them into

    Filed under:
    An RSS Feed for My "Working with Data in ASP.NET 2.0" Tutorials
    14 March 07 01:49 PM | Scott Mitchell

    There is now an RSS feed available for my Working with Data in ASP.NET 2.0 Tutorials series. There are currently 53 tutorials online at (as well as the first 13 available on the MSDN website), but there will be 75 in total.

    What better way to be kept abreast of the latest tutorials than by subscribing to the RSS feed? :-)

    Filed under:
    An Introduction to JavaScript Object Notation (JSON)
    14 March 07 01:44 PM | Scott Mitchell

    JavaScript Object Notation (JSON) is simple, lightweight data-exchange format that is used by most AJAX implementations (although it can be used by other applications and domain spaces). It is used to serialize data structures into a text format that is especially easy to parse and evaluate directly from JavaScript code. Back in 2006, Atif Aziz approached me and asked if I'd like to coauthor an introductory article on JSON. The net result is the latest article on MSDN online, An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET.

    The article focuses on JSON - its purpose, the standard, a comparison of XML and JavaScript, and so forth. The .NET examples use Atif's open-source Jayrock library, which provides classes for reading and writing JSON text as well as serializing and deserializing JSON to .NET types and vice-a-versa. It also includes support for JSON-RPC.


    Filed under:
    Three New "Working with Data in ASP.NET 2.0" Tutorials Now Available
    06 March 07 01:50 PM | Scott Mitchell

    My Working with Data in ASP.NET 2.0 tutorials have been updated to include the three newest tutorials, which look at enhancing the GridView control's functionality:

    • Adding a GridView Column of Radio Buttons [VB | C#]
    • Adding a GridView Column of Checkboxes [VB | C#]
    • Inserting a New Record from the GridView's Footer [VB | C#]

    Like the previous tutorials in the series, all tutorials are available in C# and VB, include the complete code download as a self-extracting ZIP, and are available in PDF format.

    There are more tutorials to be released in the upcoming weeks. Next on the docket are four tutorials on working with binary data.

    Filed under:
    More Posts


    My Books

    • Teach Yourself ASP.NET 4 in 24 Hours
    • Teach Yourself ASP.NET 3.5 in 24 Hours
    • Teach Yourself ASP.NET 2.0 in 24 Hours
    • ASP.NET Data Web Controls Kick Start
    • ASP.NET: Tips, Tutorials, and Code
    • Designing Active Server Pages
    • Teach Yourself Active Server Pages 3.0 in 21 Days

    I am a Microsoft MVP for ASP.NET.

    I am an ASPInsider.