About Me

My photo
Hello, I'm a technology geek looking to upgrade my programming skills. These are some of the things I'm learning along my journey.

Friday, June 29, 2012

FormView Basics in ASP.NET

Create an empty web site with a sample SQL Server database attached. Add a web form to the web site and drag a “formView” control on the new form.

Select the arrow on the right of the "formView" control and select “New Datasource” in the dropdown menu by “Choose Datasource... “.



Choose “SQL Database” and click “OK”.




Choose the name of the database you created from the dropdown menu and click “Next”.


Make sure “Yes” is checked in the check box and a connection string name has been filled in and click “Next”.




Accept the defaults and click “Advanced”.


Check “Generate Update, Insert and Delete Statements”. Check “Use optimistic concurrency”. Click “OK”. Click “Next”.



Click “Test Query”. Click “Finished”.  




Click on "AutoFormat" from the "FormView Tasks" flyout menu.


Select a format that looks pleasing to you and click "OK".

 
Click on "Enable Paging" in the flyout menu.


Press F5 to start the debugging session to see if your "formView" shows in the browser with the data from your database.


Click on "edit" to change to edit mode and see how the format changes to the default template. The "AutoFormat" feature only covers the initial view.




To change the other "Item Templates", click on "Edit Templates" from the flyout menu.



Here you can select the "Item Template" you wish to modify by selecting the "Item Template" in the dropdown menu.



To modify a template, select the text or box in the preview and select a desired control from the "Formatting" toolbar at the top. It the "Formatting" toolbar is not visible, click on "View", hover over "Toolbars" and select "Formatting". Click on "End Editing" when done.


You can download the complete program here.

No comments:

Post a Comment