Sample App: FFAssist Using Crystal .NET for VS 2005 - Part 2
page 4 of 5
by Eric Landes
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 23216/ 44

Disecting the Administration Pages

[download sample app]

Currently, there are a few admin pages for entering data for this sample application.  The pages include AddEditPlayers.aspx, AddEditPositions.aspx, AddEditStats.aspx, and AddEditTeams.aspx.  Here I will cover the basics of how these all come together.

To start learning the new "gee whizz" features of ASP.NET 2.0, I started out by using the SqlDataSource to see how easily I could generate admin screens.  I found that it can be done quickly.

For instance, on AddEditPositions.aspx, everything but Insert is handled through drag and drop and then setting the appropriate properties.  When I created the SqlDataSource for the Positions table, I specify the fields, and the SqlDataSource automatically generates the insert, update, select, and delete statements.

Data Source Wizard

These appear to encapsulate the adapter found in Visual Studio 2002 and 2003 in a one-step data source.  Also, you can configure this to automatically create and use a connection string from your config file, a handy feature.

Using the Gridview control, click on the smart-tag arrow, and select Configure Data Source.  Follow the wizard, selecting the connection information, then specify the fields to select from the table.  Click on the Advanced Options button to set the wizard to automatically generate the insert, update, and delete statements. 

To insert a new position, there are two text boxes for the position name, description, and an Add button.  Below is a sample of the actual code used to insert the data:

SqlDataSource1.InsertParameters["Position"].DefaultValue = txtPosition.Text;
SqlDataSource1.InsertParameters["Description"].DefaultValue = txtDescription.Text;
SqlDataSource1.Insert();

In this case it takes 3 lines to insert a record.  While I don't think my production applications will use this type of approach for everything, for quick admin pages not used by many, this is a quick way to get the functionality.


View Entire Article

User Comments

No comments posted yet.




Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-02-25 3:25:27 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search