Build a 5 minute ASP.NET "ToDo List"
with the XmlEditGrid
By Peter A. Bromberg, Ph.D.

Peter Bromberg

Sometimes its the simplest, fastest solution to a need that ends up seeming to be the most satisfying and valuable.

A couple of years ago Susan Warren, formerly of Microsoft fame and now on to bigger and better things, wrote a marvelous ServerControl that overrides the DataGrid. Susan's grid offers several interesting features that make it extremely useful for certain types of applications - namely, it loads its DataSet directly from an XMLDocument file, and second, it already has all the edit / update / delete code "wired in". What this means is that without writing a line of code, you can plop one of these on to your WebForm, set the XmlFile property, and have a fully - functional editable grid, with no database required. The only thing you would need to do beyond this is to ensure that the identity your WebForm runs under has write permissions on the VRoot so that the Xml file can be persisted to disk on the server.



Recently, a co-worker and I, who both work "remotely" on a project, had a lengthy list of "TO DO" items from a technical review of our work, and so I remembered Susan's grid and decided that this was as good a time as any to put it to good use.

I made a couple of changes to Susan's source code (which is included, with the changes) in order to make this more "portable" and self-contained for our purposes. First, I changed the scripts folder to be local to the particular project and altered the code to always look for it as a subfolder of the Web Application. In the case of the XmlEditGrid, this folder only holds the images that are used for the EDIT, DELETE and SAVE icons. Second, I altered the grid code, which was always expecting the EDIT and DELETE Template columns to be on the left, to look for them on the right, which would be the case when you custom design your grid properties in the property sheet and have a number of columns. Finally, I made the DataSet for the XmlEditGrid a public field, which makes handling paging and sorting much easier.

Further, I set up the web page so that you could pass the name of the Xml Data file on the querystring so that more than one "TODO" list could be used at will. If there is nothing on the querystring, the "Default.xml" file is used.

The schema for the required Xml File is very simple; here's a snippet:

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Tasks>
<Priority>2</Priority>
<Developer>Jack</Developer>
<TaskName>Show name in Businessfinder not just Business code</TaskName>
<TaskDescription>need to look at Business finder control and see if this is allowed</TaskDescription>
<DateEntered>2004-06-07</DateEntered>
<DateCompleted />
<Notes />
</Tasks>
<Tasks>
<Priority>1</Priority>
<Developer>Joe</Developer>
<TaskName>Taborder</TaskName>
<TaskDescription>tab order of controls on each tab. need to allow for Group boxes also.</TaskDescription>
<DateEntered>6/7/04</DateEntered>
<DateCompleted />
<Notes>Don't need this right away?</Notes>
</Tasks>

Here's the grid, with paging enabled, in its default view:

And here is the XmlEditGrid in Edit mode:

Another nice feature of this simple app is that you can download the Xml file in your browser, and load this into Excel 2003 as an "Xml List", nicely formatted, and sort it based on Completed date or other columns and use it for reporting purposes.

I've included a sample Xml file that you can use as a model. To run the project, unzip it in the folder of your choice, and set the EditGridToDoListWeb subfolder as an IIS Vroot. You can also run my included MKVDIR.EXE utility which is in this folder, to autmatically set this with all the proper settings. If you do, you'll notice you now have a new Windows Explorer context menu choice "Make VRoot Here" that allows you to right-click on any folder, and make it into a virtual directory with all the proper settings to be used in VS.NET.

Download the Solution that accompanies this article


Peter Bromberg is a C# MVP, MCP, and .NET consultant who has worked in the banking and financial industry for 20 years. He has architected and developed web - based corporate distributed application solutions since 1995, and focuses exclusively on the .NET Platform.
Article Discussion: