ASP.NET Lecture 4

4,367 views
4,222 views

Published on

This lecture presents
Data Binding
Rich Data Controls

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,367
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • DataBindingpageDataSourcePage pageError Bonus
  • RichControlspage
  • DataSourceControlpageEditing, Deleting , InsertingMaster, Detail View.
  • This is not the only available architecture
  • Components of the 2nd and 3rd tier can be put in a class library project (.dll)
  • page
  • ASP.NET Lecture 4

    1. 1. ASP.NET 4.0Julie IskanderMSC. Communication and Electronics
    2. 2. Lecture Outlines Data Binding Rich Data Controls n-tier architecture
    3. 3. Data Binding
    4. 4. Programatic DataBinding Using Control Properties ◦ DataSource  a collection (a list, reader, dataset) ◦ DataTextField ◦ DataValueField Don’t forget to DataBind();
    5. 5. Declarative Data Binding Single-value Binding Repeated-value Binding
    6. 6. Single-Value Binding <%# expression goes here %> Expression can be: ◦ A function (must be protected, public) ◦ A property (must be protected, public) ◦ A string literal or an mathematical expression Bound to TextBox, Label, LinkButton,….etc Must call Page.DataBind() or Control.DataBind()
    7. 7. Repeated-Value Binding Use DataSource to bind to collection and Use DataTextField and DataValueField to bind the Value and Text of the control in the aspx Never forget to call DataBind()
    8. 8. Convert from an HTML to an aspx page
    9. 9. Rich Data Controls
    10. 10. Rich Data Controls Binding GridViews, DetailViews,FormView Create a link between the data object and the data cotrol OR Finally,
    11. 11. Convert from an HTML to an aspx page
    12. 12. Data Source Controls Directly connect to a database, execute a query, loop through the records in the result set, and display them on a page. Designer Support No data access code.  Includes: ◦ SqlDataSource ◦ ObjectDataSource ◦ AccessDataSource ◦ XmlDataSource ◦ SiteMapDataSource
    13. 13. Data Source Controls Displaying Inserting Updating Deleting
    14. 14. Data Source Binding in the PageLife Cycle1. Page Initialization and Page Load2. Control events handling3. Data source controls perform updates (insert, update, delete)4. Page PreRender5. Data source controls performs queries and fill controls (Selecting and Selected Events fired)6. Page is rendered then Disposed
    15. 15. Convert from an HTML to an aspx page
    16. 16. N-tier architecture
    17. 17. N-Tier Architecture
    18. 18. N-Tier Architecture Database code MUST NOT be directly in the client, but encapsulated in classes. Easier maintenance and extension Appropriate for all types of applications (small/medium/large and desktop/Web) applications. Implementation: ◦ Create the front-end user interface (Windows Forms or Web Forms) ◦ Create the business rule component class library ◦ Create a data layer component class library to
    19. 19. N-tier layers User Interface Business Access Layer (BAL) to wrap the business rules and logic (if needed) Business Object Layer (BOL) to wraps each database table or business object Data Access Layer (DAL) to perform database operations
    20. 20. ObjectDataSource Controls Use ObjectDataSource is used with the DAL classes Instead of SQLDataSource Controls ◦ Maintenance nightmare ◦ Lack of flexibility
    21. 21. Convert from an HTML to an aspx page
    22. 22. Reading Assignment #4 Using Stored Procedures Designing layered .NET Applicationshttp://msdn.microsoft.com/en-us/library/ms973829.aspx
    23. 23. Lab #4 Bind Categories in regiter.aspx to Categories table through SQLdatasource control Add a new Customer through the registeration Page by using a data component Create Page to see and edit all Customer Data using DetailsView or FormView
    24. 24. Bonus Add a page to see, edit , insert new books and upload images
    25. 25. REFERENCES [1] Beginning ASP.NET 4 In C# 2010, Matthew Macdonald, Apress [2] Web Application Architecture Principles, Protocols And Practices, Leon Shklar And Richard Rosen, Wiley [3] Professional AS P.NE T 4 In C# And VB, Bill Evjen, Scott Hanselman And Devin Rader, Wiley [4] Pro ASP.NET In C# 2010, Fourth Edition,matthew Macdonald, Adam Freeman, And Mario Szpuszta, Apress

    ×