views:

130

answers:

4

I have need to provide a way for users to edit tables in ASP.Net. The tables are simple (no master/detail relationships), but there are likely to be a lot of them. What's the quickest/simplest way to provide a view/edit interface to a table, even considering commercial options (but not Iron Speed Designer. That thing is ridiculously expensive for what I need)?

In its most simple/ideal configuration, I'd want to point a control at a table and be done. I've looked at a few ORM solutions, but they all try to be a swiss army knife which just piles on the complexity and tend to be beasts unto themselves.

Is there something that is crazy simple that can help me here? Or should I just dive into SubSonic or something similar?

+4  A: 

Try DynamicData from microsoft, built in to asp.net 4, avalable as download for earlier versions.

David Waters
+1  A: 

Here's a tutorial on how to do it using a standard ASP.NET Gridview.

Ryan Hayes
That is exactly what I've been doing for years that makes me want to poke my eyes out with a sharp stick...
Tim Coker
Please mark your selected answer as the answer (using the green checkmark). Downvoting other answers that aren't the optimal one is not how StackOverflow works. (i.e. This answer gets the job done).
Ryan Hayes
I understand how SO works, and I appreciate your input. It may get the job done, but isn't at all what I was looking for and wasn't useful in this case. (when did the 24 hour limit on accepting answers get removed?)
Tim Coker
+5  A: 

Dynamic Data is a very easy way to edit database tables via ASP.Net. I had absolutely no knowledge of it, but I set up a website to edit a small database in literally 5 minutes, using one of Scott Guthrie's blog posts. It handled the simple foreign key relationships I had as well.

Graham Clark
Thanks for the link. It looks very near to what I want. Will look into it further. I <3 teh Gu.
Tim Coker
A: 

After some research, the quickest thing I found turns out to be just using linq to sql with a GridView. I was looking for a solution that can easily integrate into existing pages. Without the benefit of auto-scaffolding and generated pages, Dynamic Data kinda misses the mark. 99% of what I wanted was to avoid getting into writing SQL statements and handling the UpdateCommands manually.

Here are the steps I wrote up for my own personal reference. It relies heavily on the designers, but for what I need, this is perfect:

  1. New project (or existing project)
  2. Add LinqToSqlClass file to project
  3. Add Relevant tables from datasource to design surface (use server explorer)
  4. Build project (so that datacontext class will get generated)
  5. Go to aspx page
  6. Drag a linqdatasource object from toolbox.
  7. Configure datasource (make sure to enable update if necessary)
  8. Drag a gridview from toolbox
  9. Set datasource to linqdatasource object you just created
  10. Customize columns if necessary (ie, set readonly property on non-editable columns, hide non-relevant columns.)

As far as dynamic data is concerned, the documentation is currently lacking. There's a LOT of stuff that references earlier versions that doesn't work quite the same now. I watched the videos here and followed the steps here, but ultimately ran into problems when I tried hiding non-editable columns. The update statement generated by linq didn't reference the primary key and I got the Row not found or changed error. I gave up and used the solution above.

Hope this helps someone else in the future!

Tim Coker