Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Need help with ASP.NET

Hi Everyone,

I've been playing around with .NET for a couple months, and I've been struggling to figure out the best way to do something.  Any and all input is welcome.

I'm trying to build a form to allow users to edit a record from our Customers table in a SQL Server 2000 database.  What I'm having trouble with is figuring out the best way to present the data and to successfully write any changes back to the database.

I want to (as much as possible) take advantage of the new .NET server controls for things such as data validation, etc.  With that said, the first thing I looked at was a DataGrid control.  However, the problem I ran into with the DataGrid is that it only displays records horizontally.  The table I'm using has around 40 fields and causes the grid to be too wide, and I hate horizontal scrollbars.

Anyway, since I'm so new to ASP.NET, I get the feeling that there are better, more efficient ways to do things that I just haven't explored yet.  Has anyone here built anything similar to this?

Andy Shyne
Thursday, September 19, 2002

Hello Andy,

  Well, I've had problems sometimes with the DataGrid, but something very powerful is its Template Columns.

  I recommend that you look into the template columns, because you can accomplish quite a bit of stuff with them, and still benefit from the built-in DataGrid things like paging and the row handling (and its events).

Michael Giagnocavo
Thursday, September 19, 2002

You might want to look at the DataList control. It's more free-form in layout than the DataGrid.

If you're only showing and editing one record at a time, then there's no need for any of the list controls, just a simple form.

What I would do in that situation is have the page have a property called Customer that's a DataRow (or a strongly typed DataRow). Bind all of your form elements to columns in that row, like so:

Name: <asp:TextBox id="CustomerNameTextBox" runat="server" Text='<%# Customer["CustomerName"] %>' ></asp:TextBox>

When the page is loaded, you fill Customer with the right data and then do a Page.DataBind().

Luke Duff

Luke Duff
Thursday, September 19, 2002


A excellent online resource for a tutorial on the DataGrid is at the 4GuysfromRolla site.

They are currently running a series of articles called "An Extensive Examination of the Datagrid web Control" at

BTW, if you are doing anything with Datagrids, THE resource that you need to check out is Dino Esposito's  "Building Web Solutions with ASP.NET and ADO.NET" book. He makes Datagrids sing and dance in the book :-).

He is an excellent author and is one of the featured columnists in MSDN magazine.


Anil John
Thursday, September 19, 2002

You might take a look at the QuickStarts from the Framework SDK as well - they'll walk you through the basics of both the DataGrid and the DataList, so you can at least see what's possible.

Mike Gunderloy
Friday, September 20, 2002

Heck, I've got an app that will probably go live next week where I've got a DataGrid inside a DataList, which was really kind of neat to code...

Dave Rothgery
Saturday, September 21, 2002

*  Recent Topics

*  Fog Creek Home