ASP.NET Data Binding. Slide 2 Lecture Overview Understanding the ASP.NET data binding model.

Slides:



Advertisements
Similar presentations
Internetteknologi (ITNET2) Presentation 21: ASP.NET Advanced.
Advertisements

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.
Asp.NET Core Server Controls. Slide 2 Lecture Overview Understanding the types of ASP.NET controls HTML controls ASP.NET (Web) controls.
Introduction to Database Processing with ADO.NET.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
ASP.NET and ADO.NET. ASP.NET Server Controls Intrinsic Controls: These controls correspond to their HTML counterparts. –Ex. Textbox, listbox, button,
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Chapter 8 Binding Data to Web Controls. ASP.NET 2.0, Third Edition2.
Chapter 9 Using the SqlDataSource Control. References aspx.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
Chapter 10 Managing Data with ASP.NET. ASP.NET 2.0, Third Edition2.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
Welcome  30 Question & 30 Minutes  Question Will Move Automatically After 1 Min Your Exam Start Now Lecturer : Zalak Thakrar.
ASP.NET Part 4 Instructor: Charles Moen CSCI/CINF 4230.
Chapter 10 Accessing Database Files Programming In Visual Basic.NET.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.
Chapter 71 Building Data-Driven ASP.NET Applications Introduction to ASP.NET By Kathleen Kalata.
Web Controls Chapter-7. Page  2 Synopsis  Stepping Up to Web controls  Basic Web control classes  Web control classes  Web control Base class  Units,
1 ASP.NET ASP.NET Rina Zviel-Girshin Lecture 4. 2 Overview Data Binding Data Providers Data Connection Data Manipulations.
Developing Web Applications Using Microsoft ® Visual Studio ® 2008.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
IT533 Lectures DataBinding Controls. Installations Microsoft® SQL Server® 2008 Express Download the sample MDF files from the course’s web site CodeWeek3.zip.
CIS 375—Web App Dev II ASP.NET 10 Database 2. 2 Introduction to Server-Side Data Server-side data access is unique in that Web pages are basically ___________.
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
1 Web-Enabled Decision Support Systems Database Connectivity in Web Applications Don McLaughlin IE 423 (304) West.
Ventsislav Popov Crossroad Ltd.. 1. ASP.NET Data Source Controls  SqlDataSource  EntityDataSource  ObjectDataSource 2. Entity Data Model and ADO.NET.
Delivering Excellence in Software Engineering ® EPAM Systems. All rights reserved. Data Binding in ASP.NET.
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.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
Session 8: ADO.NET. Overview Overview of ADO.NET What is ADO.NET? Using Namespaces The ADO.NET Object Model What is a DataSet? Accessing Data with ADO.NET.
Chapter 8 Working With Databases in ASP.NET. Listing 8.1 – ShowListControls Uses The SqlDataSource control for estabishing database connectivity and.
WaveMaker Visual AJAX Studio 4.0 Training Basics: Building Your First Application Binding Basics.
ADO.NET Part 2. Slide 2 Overview Slide 3 Introduction to the DataGridView Control It’s a two-dimensional grid containing rows and columns Its use in.
ASP.NET More on searching databases 1ASP.NET, More on searching databases.
Using Adapter Wizard ISYS 512. Data Adapter Wizard – 2 nd Level of Using ADO.Net Configure Data Adapter and generating a dataset: –From the Data tab of.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
TRAINING SESSIONS.NET Controls.  Standard Controls  Label  Textbox  Checkbox  Button, Image Button, Image control  Radio Button  Literal  Hyperlink.
Reference: “ASP.NET 2.0 Illustrated” by Alex Homer and Dave Sussman. -ch3 illustrated book
Introduction to ADO.Net and VS Database Tools and Data Binding ISYS 350.
Ventsislav Popov Crossroad Ltd.. 1. ASP.NET Data Source Controls  SqlDataSource  EntityDataSource  ObjectDataSource 2. Entity Data Model and ADO.NET.
Making the Most of WinForms 2.0 Data Binding Rajiv Sodhi Microsoft India.
BlackBerry Applications using Microsoft Visual Studio and Database Handling.
ASP.NET Data Binding. Slide 2 Lecture Overview Understanding the ASP.NET data binding model.
Unit 6 Repetition Processing Instructor: Brent Presley.
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.
Understand Databound Controls Windows Development Fundamentals LESSON 4.2A.
Module 10: Data Access in ASP.NET. Overview Overview of the ASP.NET Data Access What is Data Access List of Data Source Control What is Data Bound How.
Working with Data Lesson 4. Objectives DataSource Controls A requirement for most modern Web sites is that they be dynamic. –Static pages are not often.
Chapter 10, Slide 1Starting Out with Visual Basic 3 rd Edition Chapter 11 Developing Web Applications.
Introduction to Database Processing with ADO.NET
Current Popular IT I Pertemuan 5
Introduction to Database Processing with ADO.NET
Active Data Objects Binding ASP.NET Controls to Data
Unit 8.2 How data can be used Accessing Data in Views
ASP.NET and ADO.NET.
Microsoft Visual Basic 2005: Reloaded Second Edition
Lecture Set 10 Windows Controls and Forms
Using List Controls with SQL Server
Web Development Using ASP .NET
Chapter 10 Accessing Database Files
ASP.NET and ADO.NET.
Active Data Objects Binding ASP.NET Controls to Data
Presentation transcript:

ASP.NET Data Binding

Slide 2 Lecture Overview Understanding the ASP.NET data binding model

Slide 3 What is Data Binding? We evaluate, at run time, expressions to get data from In-memory tables Server-side variables And other things

Slide 4 Creating a Binding In the ASPX page (not the C# file), we embed expressions in some “special” character strings Data binding expressions are contained between

Slide 5 Executing a Binding Data binding has a place in the page lifecycle It occurs automatically in some cases depending on the setting of control properties In some cases, you must force the binding to execute Call DataBind() on the page or control this.DataBind()

Slide 6 Binding Example 2 Bind to a form variable

Slide 7 Binding Example 3 Use data binding to call a function on the current page (The function is named SampleFunction) <asp:Label ID="Label2" runat="server" Text=" ">

Slide 8 Binding bee stings From asp-net-what-is-the-difference-between-and asp-net-what-is-the-difference-between-and

Slide 9 Possible Data Sources Anything that can be enumerated ( foreach loop) can serve as a data source Collections for example Dictionary and so on ADO.NET DataSet and DataTable We bind controls to data sources

Slide 10 ASP.NET Data Source Controls They add a layer of abstraction to simplify your life They create the SqlDataAdapter, DataSet and DataTable for you They take care of the binding details too SqlDataSource, ObjectDataSource, XmlDataSource

Slide 11 ASP.NET SqlDataSource It gets declared in the.ASPX file. It can be created programmatically or via a UI tool Define a connection string to a db Build the statements Enabled updates deletes (optional) Test the query

Slide 12 ASP.NET SqlDataSource Select an existing connection or create a new one Same connection that you have been working with

Slide 13 ASP.NET SqlDataSource Select the tables and fields

Slide 14 ASP.NET SqlDataSource Optionally generate INSERT, UPDATE, and DELETE statements

Slide 15 ASP.NET SqlDataSource The results

Slide 16 Using the SqlDataSource Once a data source has been created, we bind controls (and other things) to it

Slide 17 Binding (Simple) We associate an ASP control to a single value It can be just about anything An executable expression A variable A data binding expression This is what we did in the preceding example

Slide 18 Binding (Repeated) Repeated (list) We bind to a list (hence repeating data) Repeated data binding is used with “list” controls such as list boxes and combo boxes

Slide 19 Types of Complex Bound Controls Controls can be bound to a data source Basically, repeating controls are of three types List controls use a template for each item found in the data source Iterative controls allow you to create a custom template for each row that is bound View controls are the richest ( DetailsView, FormView, GridView ) More later

Slide 20 List Controls These are our ListBox, DropDownList, CheckBoxList and RadioButtonList They display a single field of information having multiple rows The can be associated with a single-field hidden “key”

Slide 21 List Control Binding Properties The DataSource and DataMember properties together bind a control instance to a data source (or DataSourceID ) DataValueField : Set to the data source field that you want the to behave as a key DataTextField : Set to the data source field that you want the user to see The DataKeyField contains the primary key

Slide 22 Data Binding (Using a Data Source - 1 ) These properties can be set Using the Properties window Declaratively in.aspx files Programmatically Call DataBind to perform the binding

Slide 23 Important Binding List Controls (Example)

Slide 24 Binding List Controls (Example) Programmatically bind a ListBox lstDemo.DataSourceID = SqlDataSource1"; lstDemo.DataTextField = "fldInvoiceNumber"; lstDemo.DataBind();

Slide 25 List Controls (Members) SelectedIndex contains the 0-based index of the selected list item -1 if no item is selected SelectedItem gets the selected item from the list SelectedValue gets the value of the selected item Set AutoPostBack to true to fire a postback when the user selects an item We have discussed these previously

Slide 26 Binding Order Page.Init and Page.Load events fire Other control events fire Updates occur for changed controls (Inserting, Inserted, Updating, Updated events fire) Page.PreRender fires Data sources are queried and the data displayed