1 Data Bound Controls II Chapter 15 - 16. 2 Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.

Slides:



Advertisements
Similar presentations
11 Getting Started with ASP.NET Beginning ASP.NET 4.0 in C# 2010 Chapters 5 and 6.
Advertisements

Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
User Controls, Master Pages, GridView. Content User Controls Styles, Themes, Master Pages Working with Data GridView Muzaffer DOĞAN - Anadolu University2.
Chapter 9 Customizing Data with Web Controls. ASP.NET 2.0, Third Edition2.
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Chapter 12: Using ADO.NET 2.0 Programming with Microsoft Visual Basic 2005, Third Edition.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Integrating Access with the Web and with Other Programs.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Figure 1. Hit analysis in 2002 of database-driven web applications Hits by Category in 2002 N = 73,873 Results Reporting 27% GME 26% Research 20% Bed Availability.
 Pages made using data in a database  Use scripting languages  Use of RDMS  Look and feel by templates, CSS  High scaling  Admin pages as back end.
Chapter 2 Querying a Database
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
Chapter 3 Maintaining a Database
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
Databases and LINQ Visual Basic 2010 How to Program 1.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
Chapter 1 Databases and Database Objects: An Introduction
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
IT 211 Project Integration and Deployment Lab #11.
Creating a Web Site to Gather Data and Conduct Research.
E-Commerce: Introduction to Web Development 1 Dr. Lawrence West, Management Dept., University of Central Florida Topics What is a Web.
1 Databound Controls. 2 Objectives You will be able to use design time data binding to display and update SQL Server database data without writing any.
1 Web-Enabled Decision Support Systems Database Connectivity in Web Applications Don McLaughlin IE 423 (304) West.
1 Working with MS SQL Server Textbook Chapter 14.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
MS-ACCESS BY SANGEETHA PARTHASARATHY Topics to be covered §Comparing Values in Selection Criteria §Calculating Values in a Query §Changing the appearance.
Key Applications Module Lesson 21 — Access Essentials
CIS 338: Using Queries in Access as a RecordSource Dr. Ralph D. Westfall May, 2011.
Working with GridView Control: Adding Columns. Adding Buttons to a Bound GridView: 1. Drag the WebProduct table from Data connection to a page 2. Demo.
Caching Chapter 12. Caching For high-performance apps Caching: storing frequently-used items in memory –Accessed more quickly Cached Web Form bypasses:
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
1 Chapter 12 – Web Applications 12.1 Programming for the Web, Part I 12.2 Programming for the Web, Part II 12.3 Using Databases in Web Programs.
ASP.NET The Clock Project. The ASP.NET Clock Project The ASP.NET Clock Project is the topic of Chapter 23. By completing the clock project, you will learn.
Chapter 8 Working With Databases in ASP.NET. Listing 8.1 – ShowListControls Uses The SqlDataSource control for estabishing database connectivity and.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
1 Chapter 20 – Data sources and datasets Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
TRAINING SESSIONS.NET Controls.  Standard Controls  Label  Textbox  Checkbox  Button, Image Button, Image control  Radio Button  Literal  Hyperlink.
11 The Repeater Control. 22 Objectives You will be able to use a Repeater Control to display data obtained with a SQL query with custom formatting.
Reference: “ASP.NET 2.0 Illustrated” by Alex Homer and Dave Sussman. -ch3 illustrated book
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 8 – Integrating a Database with a FrontPage.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 12 Accessing.
1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Editing and Designing Databases.
Chapter 12© copyright Janson Industries Java Server Faces ▮ Explain the JSF framework ▮ SDO (service data objects) ▮ Facelets ▮ Pagecode classes.
1 CS 3870/CS 5870: Note07 Prog 4. Master Pages Creating a master page based on another master page MainMasterPage –For all Progs and Tests Prog4MasterPage.
1 CS 3870/CS 5870: Note07 Prog 4. Master Pages Creating a master page based on another master page MainMasterPage –For all Progs and Tests Prog4MasterPage.
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
11 Getting Started with ASP.NET Beginning ASP.NET in C# and VB Chapters 1 and 2.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 8 1 Microsoft Office Access 2003 Tutorial 8 – Integrating Access with the.
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
11 User Controls Beginning ASP.NET in C# and VB Chapter 8.
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Introduction In this chapter you will learn: – Basic database concepts – How.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Creating Data Base & Sql Data Source
Part 1 of 2 Creating SQL Database and Binding to GridView
CIS16 Application Programming with Visual Basic
Using List Controls with SQL Server
Database Applications
Creating Data Base & Sql Data Source
Chapter 10 Accessing Database Files
Presentation transcript:

1 Data Bound Controls II Chapter

2 Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available to display components Use a GridView control to display data from a Data Source control. All without writing any C# code.

Data Binding Permits us to bind a control to a data source. Example: SQL Server database table. Many others. Control automatically shows data from the data source. No C# code required. Can update the data source with new values input by the user.

4 The Northwind Traders Database We will use the Customers table from the Northwind Traders database for an example today. Need own copy so that we can modify it. Download script from the class web site: File create_customers.sql Put the file into a convenient folder.

5 Script create_customers.sql

6 Executing the Script Set up VPN connection.

7 Check the Table in Visual Studio

8 Show Table Data

9 Table Customers

10 Set Primary Key In order to update the table, it must have a Primary Key. Set in the standard Northwinds Database version of the table. Not in our copy. View Server Explorer Expand Customers table Open Table Definition

11 Set Primary Key Right-click here Select Set Primary Key

12 Set Primary Key

13 Data Source Controls Family of ASP.NET controls with similar functionality and identical interfaces Connection information Query information Parameters Avoid need to write low level code to access the database. Bind to display controls to show the data on a web page.

14 The GridView Control Displays data in a grid Think Excel spreadsheet Binds to a Data Source control Many properties! Control appearance and behavior

15 Create a New Web Site

16 Rename the.aspx file

17 Drag a SqlDataSource to the Page

18 Configure the DataSource Click here

19 Set Up a new Connection Click here

20 Add Connection Click here

21 Configure the DataSource Click here

22 Save the Connection String Say “yes”

23 Specify the Query

24 Test the Query Click here

25 Query Result Click here

26 The SqlDataSource Ready for Action The SqlDataSource control holds the connection and query information that will be used by a data bound control.

What We Wrote

$ Expressions Will be evaluated by the server as the.aspx file is processed. Invokes an expression builder ConnectionStrings in this case. Does not emit HTML. Used only to set a property value of the enclosing ASPX object SqlDataSource in this case.

web.config

$ Expressions The expression builder ConnectionStrings will return the connection string with name wpusr40 from the section of web.config. That string will be the value of the ConnectionString property of SqlDataSource1. Equivalent to writing SqlDataSource1.ConnectionString = WebConfigurationManager.ConnectionStrings["wpusr40"].ConnectionString; in Page_Load.

31 Drag a GridView onto the Page

32 Bind to the SqlDataSource Click here to select data source

33 Bind to the SqlDataSource Select SqlDataSource1

34 The GridView The GridView is now specific for the data source.

Try it!

Zoom Out and Resize the Window 36

37 Enable Paging

38 View the Source

Paging Enabled 39

40 Make it look nicer. Click on the GridView’s smart tag and select Auto Format. Explore the choices

41 Enable Sorting

42 Run the App! Note the page selections. Click on the column headings to sort by that column.

43 Compare Paging to Scrolling Back in the design view Click on the GridView’s smart tag and unselect Enable Paging. Build and run the app again. Try the scroll bar.

44 Paging Disabled

45 Adding Insert, Update, and Delete Currently we can only display the table contents. No capability to modify the database. Look at the source. Find

46 The SqlDataSource

47 Add Update Capability To add the capability of updating the database, go back to design view. Click the smart tag on SqlDataSource1. Click Configure Data Source

48 Add Update Capability

49 Add Update Capability Click here.

50 Add Update Capability Click here.

51 Add Update Capability Click here.

52 Add Update Capability Click here.

53 Add Update Capability Click here. Click here to test.

54 Back in Design View Click on the GridView and then click on the smart tag which will appear at the upper right corner.

55 Adding Update Capability Select Enable Editing and Enable Deleting

56 Source View

57 Try it! Click on “Edit” link to edit a row.

58 Doing Edits Edit textboxes then click “Update”.

59 Updated Field

60 Back in Visual Studio Server Explorer

61 Buttons Instead of Links Click the GridView smart tag and select Edit Columns

62 Buttons Instead of Links Click here.

63 Buttons Instead of Links 1. Select “CommandField” 2. Select Button from dropdown list. 3. Click OK

64 Visual Studio Design View

65 The App in Action