Click here to Skip to main content
Click here to Skip to main content

Quick Screen Development in ASP.NET

, 20 Jul 2004
Rate this:
Please Sign up or sign in to vote.
Auto Generate the ASPX page quickly

Introduction

Developing the screen for various tables has been a boring activity. This is small step towards automating the screen generation for the aspx pages.

Currently this application can generate the aspx tags for SQL Server 2000 table.

The idea is

a. For every column in the table , A Label field is required on the screen.

b. For a natural column in the table, A text box is required on the screen.

c. If the column is not nullable , A required field validator needs to be placed on the screen.

d. For a foreign key, Usually a dropdown list is required.

d. Tab index and Max Length properties also need to be set.

To get the meta data for a table the following procedure is used. It gets the name of the column, Data Type, If it nullable, Size and if it is a foreign key.

<BR>SELECT <BR>COLUMN_NAME,<BR>DATA_TYPE,<BR>IS_NULLABLE,<BR>isnull(CHARACTER_MAXIMUM_LENGTH,0),<BR><BR>-- Identifies if it is a foreign key-------<BR>ISNULL((SELECT 'Y' FROM SYSFOREIGNKEYS WHERE FKEYID =ID AND FKEY=COLID),'N')<BR> as 'IsForeignKey',<BR>Ordinal_Position<BR><BR>FROM <BR>SYSCOLUMNS,<BR>(SELECT<BR>COLUMN_NAME,<BR>IS_NULLABLE,<BR>DATA_TYPE,<BR>CHARACTER_MAXIMUM_LENGTH,<BR>Ordinal_Position<BR><BR>FROM <BR>INFORMATION_SCHEMA.COLUMNS<BR><BR>WHERE<BR>TABLE_NAME <A href="mailto:=@Table_Name">=@Table_Name</A>) AS A<BR><BR>WHERE <BR>ID <BR>IN<BR>(SELECT <BR>ID <BR>FROM <BR>SYSOBJECTS <BR>WHERE <BR>TYPE='U'<BR>AND NAME <A href="mailto:=@Table_Name">=@Table_Name</A><BR>) <BR><BR>AND<BR>A.COLUMN_NAME =NAME <BR>Order By<BR>Ordinal_Position.
Now there are 4 classes in the application. Common.cs has all the common properties. Other classes for the controls are inherited from it. ToString() method is overriden to generate the aspx tag necessary for the control.
Steps to Generate the aspx code.

1. Create the stored procedures provided in your database.

2. Modify the connection information in the Form1.cs file. There are two places you have to modify the connection information . One inside GetTables() method and another inside ProcessTable(string TableName).

3. Execute the project. In the Window The combo shows the list of tables available. Enter the name of the table inside the text box and click the generate button.

4. Copy the code from the textbox below and paste inside the <form></form> tags inside your aspx page.

5. There you go.....

Currently this generates a label for every column, Text or Combo box depending on weather it is a table column or a foreign key, generates a required field validator for not nullable fields,sets the tab order and max length properties.

Let me know if there are other methods to generate aspx pages.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Balachandar Ganesan
Web Developer
United States United States
Balachandar Ganesan has been working in CGI India for the last 6 years. ASP.NET, SQL Server 2000, Crystal Reports, Database Performance tuning, ETL, Actuate, Cobol, CICS,DB2, Easytrieve, Flash, PaintShop Pro , SoundForge are few of the various technologies with which he has worked.
 
He is known for ability to generate applications with "just good enough" features in a short time.
 
He has written whitepapers on Software development process improvement as well.
 
Image, Video and Audio editing are his hobbies. He is also the editor of his company newsletter, Manager of cricket and volleyball teams, Vice-President of Toastmasters club.
 

Comments and Discussions

 
GeneralSource Code Pinmemberdamonr26-Jul-04 6:00 
GeneralCodesmith PinmemberSteven Campbell22-Jul-04 4:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411023.1 | Last Updated 21 Jul 2004
Article Copyright 2004 by Balachandar Ganesan
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid