16. What is ADO.NET? Set of classes that expose data access services to the .NET programmer ADO.NET provides a rich set of components for creating distributed, data-sharing applications It is an integral part of the .NET Framework, providing access to relational data, XML, and application data
17. WebForm Apps WinForm Apps ADO.NET DataSets SQLConnection SQLCommand SQLDataAdapter SQLDataReader SQL Data Providers SQL Data XML Data Oracle Data …
18. Objects Instead of DataSets we use classes Extensible Can embed logic and validation A more OO approach
19. WebForm Apps WinForm Apps Objects/Entities Data Sources SQL Data XML Data Oracle Data …
20. DataSets or Business Objects Why use DataSets A highly functional container for data that can be strongly typed Automatic change tracking for contained data Seamless data-binding support Why Use Objects Business Objects (NHibernate, NTiers, LINQ to SQL, LINQ to Entities) Light weight Good data-binding support Extensible and OO Very easy to use No SQL command Strings
22. LINQ to SQL/Entities Brand new in the .NET 3.5 Framework Easily access and query your database through classes Logical access to class hierarchies Supports Inheritance Intuitive to use
23. DBML File Database Mapping Language Contains a mapping of classes to database tables Has built in logic to handle selection, updates and deletes Can be customized www.hookedonlinq.com
24. var customers = from c in db.Customers where c.FirstName.StartsWith(“A”) select c SQL Syntax
25. var customers = db.Customers.Where(c => c.FirstName.StartsWith(“A”); Lambda Syntax
26. Challenge, use this instead of SQL Server Management Studio for a month LINQPad
27.
28. See our Rules http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterLINQ.aspx
31. Data Binding Data Data source From MSDN: Data binding is the process that establishes connection between the application UI and business logic Binding controls to data from database Bind a grid on Webform to a database table Simple, convenient, and powerful way to create a read/write link between the controls on a form and the data in their application
32. Databinding the GridView (code) C# NorthwindDataContext db = newNorthwindDataContext(); GridView1.DataSource = db.Customers; GridView1.DataBind(); English Instantiate our data access class Make the datasource of GridView1 all the customers from our database Bind the Grid
46. Other Data Bindable Web Controls Bindable to Lists DataList DetailsView FormView Repeater/ListView DropDownList ListBox CheckBoxList RadioButtonList Bindable to Properties/Columns Most other controls
47. Data-Bound Controls Most controls in .NET Framework support data binding Controls inherit from the WebControl base classwhich implements IDataBindingsAccessorinterface Important Data-binding properties DataSource DataMember DisplayMember ValueMember Design your own controls or purchase 3rd party controls
49. Passing Parameters between pages Pass parameters to pages or controls Pass parameters to our data sources Parameters can be obtained from: Query String Session Variable Control Property Hidden Field Cookie
50. 1. Create a CustomerDetails.aspx Add a Details View and create a new Datasource
63. Why use Validations? Seamless verification of data fields Check for mandatory fields Check for correct data formats Check for data ranges Reduces incorrect data entered into your database Prevent possible runtime exceptions
65. Validation Types Client-Side Validation Validations are performed before the form is posted back Quick and responsive for the end user Insecure Server-Side Validation Validation checks are performed on the server Secure because these checks cannot be easily by passed Sometimes can be slow Recommendation Use both the types This approach provides the best of both worlds Client Show/view Data Enter Client Server
66. ASP.NET Validation Server Controls RequiredFieldValidator CompareValidator RangeValidator RegularExpressionValidator CustomValidator ValidationSummary
67. To put the Northwind database up on the web? CRUD for all tables Pages for all tables Validation So how long do you think it would take...
69. Awesome starting point Learn more from http://www.asp.net/dynamicdata/ ASP.NET Dynamic Data
70. Extend what’s given to you and you can make really great websites You can use it as a framework
71.
72. Any issues ... questions PeterGfader@ssw.com.au EricPhan@ssw.com.au
73. Thank You! Gateway Court Suite 10 81 - 91 Military Road Neutral Bay, Sydney NSW 2089 AUSTRALIA ABN: 21 069 371 900 Phone: + 61 2 9953 3000 Fax: + 61 2 9953 3105 info@ssw.com.auwww.ssw.com.au
74. Resources www.hookedonlinq.com http://www.asp.net/get-started/ http://weblogs.asp.net/scottgu/ http://www.asp.net/dynamicdata/ If you have the next awesome web ideahttp://www.microsoft.com/BizSpark/ http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterLINQ.aspx
Notas del editor
Click to add notesPeter Gfader Developing Windows and Web applications
Request ResponseOpen browser and browse around
Goal: Show View data to users on the webLet users enter and modify data
Show how easy it isHow many code lines did i write?Show them the old wayHuge difference!
Changes to Datasource get forwarded to databaseChanges from database get forwarded to data grid
Property DataSource and DataMember on grid
Show controls in VSDataList = More for List layout (http://msdn.microsoft.com/en-us/magazine/cc301328.aspx )DetailsView = mainly for editing (row/col switched) 1 record at a timeFormView = like detailsview but more control over html rendered code (layout) that’s goodListView = like datalist but more control again, see EA emp Repeater = same as Listview, Listview replaces repeaterDropDownListListBox = simple list of itemsCheckBoxListRadioButtonList
Go to website: telerikTelerik RAD ControlsComponent ArtInfragisticsDevexpressJanus
Suggest or common ones are querystring, hidden fieldCookies saving bits of info for all pagesE.g. Select a row from the grid and show the details in a DetailsViewPass the selected row’s ID (e.g. ContactID) as a query string parameterE.g. http://localhost:1234/MyWebApp/Details.aspx?ContactID=1
Show url with IDPostback http://www.search-cube.com/
Problem Exists Between Chair and ComputerClient database SWIFT project
ASP.NET existing Validation controls create client side script for us
CustomValidator Method Validate write your own code there (SERVER SIDE)