.netTiers
Help Wanted! If you are using .netTiers and find it as invaluable as we do, please consider giving back to the .netTiers team by helping with our effort to fully document .netTiers. To help, simply create an account and you will then be able to edit this wiki.

ASP.NET

Modified: 09/02/2010 12:46 PM by mikiurban - Categorized as: ASP.NET
Web Library

What is the Web Library

Typed DataSource Controls -vs- EntityDataSource



Web.Config Configuration





Using the Typed DataSource Controls

Strongly Typed DataSource controls: You will find that just by typing




Productivity Enabler When you select the SelectMethod Attribute, you will see via intellisense a list of all available methods from your domain. How cool is that!

Intellisense:

Simple WebForm Example: Here's an example of a simple webform in it's minimilist form, that would display a grid of all Employees with Auto-Generated columns.

Design View:| Taking the form and selecting only the columns that I want, we create a nice grid.







Data View Results: Here's the result of of the form. The wonderful part of the Typed DataSource control is that you don't have to do anything when you want to edit/insert/delete an object. You simply have the grid call the Edit/Delete/Insert command, which can be done a variety of ways in ASP.net 2.0.



Edit:

After Edit:





TypedDataSource w/ Atlas Example GridView Paging, Sorting and inline Update/Delete



Click to Enlarge











Creating the Grid

First, create a new page and add the following GridView control:

NOTE: It's very important that you specify the DataKeyNames property of the Gridview, otherwise, Insert/Update/Delete will not work.



Next, add the CustomersDataSource control to your page: This is the tough part, so strap it in!!!



Umm... That's it! And you should have a functional GridView with paging and sorting! Using Atlas: Now here comes the fun part, Atlasifying (see dictionary) your grid. As you know microsoft released an extremely useful Ajax & more library called Atlas.

More information can be found: http://atlas.asp.net



Demonstrating Atlas with .netTiers Now we want to add a filter to our page to demonstrate a new feature to NetTiers:

All Brazil Canada France Germany Italy Mexico Spain UK USA Venezuela <%= DateTime.Now %/>

Next, change the data source control above to add a parameter for the whereClause parameter of the GetPaged method. The SqlParameter allows you to define external filter controls that will be combined to generate the filter expression:





Atlas Magic: Now we can add the magic! Make sure you have a reference to the Atlas Script Manager:



We want to wrap the GridView control with an UpdatePanel:







Notice that the trigger is tied to the CountryList control so that the GridView is updated every time the selected country is changed. Poof!!! All Done.



Using the EntityDataSource Control The EntityDataSource controls is useful because it uses 100% reflection to work with the data providers. This is great when you need to change the type at runtime, or maybe you have written your own methods within the DataAccessLayer that you would like to call. You would simply use the EntityDataSource control.




OnSelecting="" OnSelected="" OnInserting="" OnInserted="" OnUpdating="" OnUpdated="" OnDeleting="" OnDeleted="" >


ProviderName (required) - an alias for TypeProperty; the name of the static property of the DataRepository class which returns a reference to the specific provider instance. ex: ProviderName="CustomersProvider" for Northwind.Data.DataRepository.CustomersProvider

EntityTypeName (required) - the fully qualified class name of the entity class that is handled by the specified data provider.

EntityKeyName - the name of the property that holds the primary key value.

EntityKeyTypeName - the fully qualified class name for the return type of the EntityKeyName property.

EnableTransaction - set to True if the EntityDataSource should rely on the EntityTransactionModule class to supply a TransactionManager object.

InsertDateTimeNames - a comma-separated list of DateTime property names to initialize to the current DateTime.Now value during an insert operation.

UpdateDateTimeNames - a comma-separated list of DateTime property names to initialize to the current DateTime.Now value during an update operation.

Filter - the value to apply to the ListBase.Filter property after a select operation (only if EnablePaging is false)

Sort - the value of the parameter to pass to the ListBase.Sort(string) method after a select operation (only if EnableSorting is false) Example: This is an example of populating a DropDownList control with data retrieved using the EntityDataSource control.







Using Many To Many Relationship Controls The ManyToManyListRelationship control manages the junction table that links your primary entity with a foreign key table. Please see highlighted code below.

Cust #:
Company Name:
Demographics: <% represents the Customers table %> <% represents the CustomerCustomerDemo link table %> <% represents the CustomerDemographics table %>




ScrewTurn Wiki version 2.0.31.