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

Slides:



Advertisements
Similar presentations
Svetlin Nakov Telerik Corporation
Advertisements

Internetteknologi (ITNET2) Presentation 21: ASP.NET Advanced.
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.
Bind Controls to Data by Using Data-Binding Syntax Web Development Fundamentals LESSON 2.5.
Asp.NET Core Server Controls. Slide 2 Lecture Overview Understanding the types of ASP.NET controls HTML controls ASP.NET (Web) controls.
ASP.NET Data Binding. Slide 2 Lecture Overview Understanding the ASP.NET data binding model.
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,
ASP.NET and ADO.NET. Bind the DataReader to a DataGrid Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\sales2k.mdb" Dim objConn.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 8 Using Repetition with Loops and Lists. Class 8: Loops and Lists Write Do loops to execute statements repeatedly Write For loops to execute statements.
Overview This presentation covers the initial overview of the different server controls. 2.
Copyright © 2014 Pearson Education, Inc. Chapter 11 Developing Web Applications.
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.
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.
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.
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.
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 ___________.
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.
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.
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.
3116 Top 10 Techniques for Microsoft.NET Framework Database Developers Cary Jensen President Jensen Data Systems, Inc.
Chapter 8 Working With Databases in ASP.NET. Listing 8.1 – ShowListControls Uses The SqlDataSource control for estabishing database connectivity and.
Security Attacks CS 795. Buffer Overflow Problem Buffer overflows can be triggered by inputs that are designed to execute code, or alter the way the program.
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.
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.
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
Week Developing Web Applications 12. Programming for the Web A Web Application Runs on a Web Server and Presents Its Content to the User Across a Network,
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.
Security Attacks CS 795. Buffer Overflow Problem Buffer overflow Analysis of Buffer Overflow Attacks.
Unit 6 Repetition Processing Instructor: Brent Presley.
Data tastes like chicken, if chicken was data.. Databinding What is it? Associating a set of data with a control Why use it? Its much easier than associating.
Understand Databound Controls Windows Development Fundamentals LESSON 4.2A.
Unit 8.2 Learning Objectives Data Warehouses – The Role of Data Warehouses The Role of Data Warehouses – Group Exercise Accessing Data in Views – Accessing.
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.
Developing Web Applications
12/9/2018 Session 9.1 Calendar and Validation Controls Using Sessions
Lecture Set 10 Windows Controls and Forms
Using List Controls with SQL Server
Module 05: Building ASP .NET Applications
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 assumed to be named SampleFunction) <asp:Label ID="Label2" runat="server" Text=" “ >

Slide 8 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 9 ASP.NET Data Source Controls They add a layer of abstraction to simplify your life We have talked about the SqlDataSource They create the SqlDataAdapter, DataSet and DataTable for you They take care of the binding details too SqlDataSource, ObjectDataSource, XmlDataSource

Slide 10 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 11 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 12 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 13 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 14 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 15 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 16 Important Binding List Controls (Example)

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

Slide 18 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 19 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

Slide 20 Understanding Eval and Bind Eval and Bind evaluate “late-bound” binding expressions and optionally formats them With one exception, the both work the same way Eval is a one-way read-only binding Bind is a two-way read-write binding