Jim Bonnie's Blog

Sep 19

Written by: jbonnie
Wednesday, September 19, 2007 3:58:32 PM 

In addition to generating your Data Access Layer for you, SubSonic comes with some other goodies that make building web applications easier. I was surprised to find that some of these controls work directly against the database schema and do not require the Data Access Layer to be pre generated at all

In addition to generating your Data Access Layer for you, SubSonic comes with some other goodies that make building web applications easier.  I was suprised to find that some of these controls work directly against the database schema and do not require the Data Access Layer to be pre generated at all..

SubSonic has a number of web controls that you can use if you follow the standard naming conventions that are recommended. This is one of the Ruby on Rails,  mantras, convention over configuration.

The Controls

Scaffold  , QuickTable, DropDown, and Many to Many Control

In addition to theses controls, there is dedicated webpage called the auto scaffold. This web page uses the subsonic data provider to allow any table that has generated code to be edited. This page needed a few changes for the post back urls to work, but I changed the page into a module by changing the inherits from a webpage into a dotnetnuke.entities.modules.portalmodulebase.

I found out something very interesting – The autoscaffold code works without a pre-generated data access layer. So this code works with simply installing subsonic and configuring a data provider.  The same goes for the scaffold controls which is pretty cool!

Running SubSonic without changing Web Config

This module supports a piece of code that wires up the SubSonic data provider at runtime. So no config changes are required. Just install this module and you will have full edit capabilities to your tables. But please be careful, most of the DNN system tables should not be updated. I would suggest using a separate database if possible for your files using this module. Download it here.

Tags:

6 comment(s) so far...

Re: Deploying the SubSonic AutoScaffold webpage as a DotNetNuke Module

Hello Jim,
You should consider me as one of your followers. I have bookmarked your site and checking it all the time for updates. I am trying to convice some peers to use subsonic for their DNN modules. Yet, I still have to prove to them it works...not yet there, but I know I will get there.
I downloaded this module and added it to my solution and I added it to a folder on my Desktop Modules. I will run it and and see how to use it.

However, here is my concern:
The reason why I was using to generated scaffolded pages, is because I wanted to be able to modify the Gridwiew as well as the FormView. For example, there are columns I don't want to display on my grid depending on the user logged in. I would like to add an extral file upload control somewhere in between the formView. I have not tested your module yet, however, I would like to know how can I customize that? Will your module output the files so I can customize those?

If that can't be done, I got to the point where I have the Module running on a page. I have the GridView working and I can add a new row (I changed the hyperlink with a call to a function that resets the pnlEdit to True (the default has been changed to False).

Now that's working. But I am a little bit lost when it comes to the Edit and Delete links. how do I change those to work within the my Control? (I know this is now an asp.net question)...thanks if you could chip in some pointers.

Thanks.

By Bebel02 on   Thursday, September 20, 2007 10:28:23 AM

Re: Deploying the SubSonic AutoScaffold webpage as a DotNetNuke Module

Sorry Jim, I am back again.
I tried to add the Module in a folder (under desktop modules). Built the solution, and it all build well. However, I am adding it to a page and then....nothing...the tiltle I did set up durin registration is there, but that's all I can see.
Am I missing something?

Thanks, (still need input on the customization though)

By Bebel02 on   Thursday, September 20, 2007 11:48:03 AM

Re: Deploying the SubSonic AutoScaffold webpage as a DotNetNuke Module

I understand the pain that you are going through. I struggled with DNN for a while since I was learning ASP.NET and SQL Server at the same time. it is the same thing for SubSonic. it can be difficult to appreciate all that it does for you if you have not written the corresponding ADO.NET, Readers, and collection classes by hand. The experience also helps with troubleshooting configuration issues that will always come up.

So hang in there, the experience will make you a better developer in the long run.

By jbonnie on   Thursday, September 20, 2007 1:31:25 PM

Re: Deploying the SubSonic AutoScaffold webpage as a DotNetNuke Module

Jim,
I could not have said that better!. You are great, and thank you for the moral support, it's definitely appreciated.

Good News, I have your implementation of the module working just fine. Some issues with DNN here and there(throwing errors unlees you refresh/rebuilld, etc...). Anyways, I was able to get that knocked out and I have my two table sweetly up and running.

QUESTION: (yeah, I know, I am bugging too much...sorry)
How can I tweak it to display only the columns I need to display (like i need to hide the Auditing columns). Also, I need to Change the Label Naming. Literally, can I customize this with maybe partial classes, etc? if so, how do I do it? any pointers on how to make that happen?
Can't wait for the impact your talk will have in Vegas.

Thanks

By Bebel02 on   Thursday, September 20, 2007 1:46:07 PM

Re: Deploying the SubSonic AutoScaffold webpage as a DotNetNuke Module

I would not try to modify the auto scaffold to customize columns. It may be possible, but it is meant as an Admin editor for quick changes.

The Scaffold web control, works on a single table at a time, and it does have a property called selectlist that allows the columns to be specified.

But what you really want to do is look at ASP.NET tutorials or books that show how to build editors that are made for purpose for your business application. A straight data grid is ok for some cases, but you will want to go the extra miles for a nice application.

By jbonnie on   Thursday, September 20, 2007 8:48:38 PM

Re: Deploying the SubSonic AutoScaffold webpage as a DotNetNuke Module

Jim,
The pointer to the Scaffold Web control did the trick. I actually used the HiddenGridColumns property to get rid of columns i did not want to display. Thanks, that did it. Also, thank you for all the advices. I will definitely keep a close look at your blog since i will be seriously using dotnetnuke and subsonic.
You made my week, Jim!
thank you!

By Bebel02 on   Friday, September 21, 2007 4:59:16 PM

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 

Navigation

Register Login

About Me

Thanks for stopping by. My name is Jim Bonnie and I have been writing software for over 20 years. After building financial data systems for Reuters for nearly 18 years I have started doing contract work and am excited about technology and currently focus on Microsoft solutions. DotNetNuke has helped provide a good introduction to ASP.NET web application development, and I am now starting to branch out into other areas. Data Access techniques and SubSonic is something that I am looking into now. This has helped me get an invitation to speak at Las Vegas at DNN Open Force 07. it was a great time. And I am looking forward to OpenForce08, where I wil be presenting on TDD for DNN.

 

Reading the codebetter blogs and attending a nothing but .net training class with JP Boodhoo helped spark my interest in ALT.NET. I attended the first conference in Austin Texas, and it was amazing to see Scott Guthrie introduce the ASP.NET MVC framework.

Add to Technorati Favorites

View blog top tags

Links

Jim Bonnie's Blog

Jim Bonnie's Blog

Jim Bonnie's Blog