PROG11044 - Advanced Web Apps 2/24/2019 Session 9.2 Data Binding Wendi Jollymore, ACES.

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

Making Things Look Nice: Visual Appearance and CSS CMPT 281.
Using the DetailsView and FormView Controls. Slide 2 DetailsView (Introduction) Use the DetailsView control to Display a single record at a time Insert,
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 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Building ASP.NET Applications 2 Lecture 3,4 T. Ahlam Algharasi 4 th Level.
ASP and HTML. Anchor Tag testAnchorTag Demo: ASPNet/ASPNETProdListSelf.ASPX.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
Session 2 Tables and forms in HTML Adapted by Sophie Peter from original document by Charlie Foulkes.
Inventory Throughout this slide show there will be hyperlinks (highlighted in blue) follow the hyperlinks to navigate to the specified Topic or Figure.
JMD2144 – Lesson 5 Web Design & New Media. ‘Div’ide and conquer One of the most versatile structure tags available is the.. tag Short for ision, it allows.
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.
Welcome  30 Question & 30 Minutes  Question Will Move Automatically After 1 Min Your Exam Start Now Lecturer : Zalak Thakrar.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
MSIS 5133 Advanced MIS - E-Commerce Spring 2003 Lecture 4: DotNet Technologies - Part 4 Using Controls with Databases Dr. Rathindra Sarathy.
Chapter 71 Building Data-Driven ASP.NET Applications Introduction to ASP.NET By Kathleen Kalata.
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
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.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
Delivering Excellence in Software Engineering ® EPAM Systems. All rights reserved. Data Binding in ASP.NET.
ASP.NET - accessing the database - datareader vs dataset - datagrid vs datalist - brief look at web matrix.
IS201 Agenda: 10/15/2013 Do form and report exercise. Identify general guidelines for form and report design. Discuss a few key points about reports in.
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.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
USING XML AS A DATA SOURCE. Data binding is a process by which information in a data source is stored as an object in computer memory. In this presentation,
XP 1 New Perspectives on XML Binding XML Data with Internet Explorer.
Sports Website Creation. In this project you will design and produce your own website.
CIS 375—Web App Dev II ASP.NET 8 More Binding. 2 The Repeater ControlThe Repeater Control 1 The Repeater control is used to display a repeated list of.
ASP.Net and HTML. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data.
HTML— More Tags, Formatting, and Lists. Formatting Tags  Bold  Italics  Underline  Big text  Small text  Subscript (H 2 O)  Superscript (10 3 )
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.
ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState.
CSE 409 – Advanced Internet Technology Today you will learn  Styles  Themes  Master Pages Themes and Master Pages.
COP 3813 Intro to Internet Computing Prof. Roy Levow Lecture 2.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Unit 11: Using server side control to display data in ASP.NET.
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.
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.
HTML. HTML: What is it? – HTML stands for Hyper Text Markup Language – An HTML file is a text file containing small markup tags – The markup tags tell.
HTML Tags BTT1O. HTML  Documents written in hypertext markup language can be interpreted by all web browsers.  This language lets the web page developer.
Advanced HTML Tags:.
June 17, 2009 Office 2007 Tips & Tricks.
Create and edit web pages 4
Unit 9.1 Learning Objectives Data Access in Code
PROG Advanced Web Apps 5/23/2018 Notes on ADO.NET (1) Wendi Jollymore, ACES.
Jim Fawcett CSE686 – Internet Programming Spring 2012
Forms.
Unit 8.2 How data can be used Accessing Data in Views
Retrieving information from forms
Arrays and files BIS1523 – Lecture 15.
Unit 9.2 Database access from code Database Cycle Review
Cookies BIS1523 – Lecture 23.
Unit 27 - Web Server Scripting
Brief description on how to navigate within this presentation (ppt)
Building Web Applications
12/9/2018 Session 9.1 Calendar and Validation Controls Using Sessions
Cheat Sheet CSCI 100 JW Ryder
Using List Controls with SQL Server
Database Applications
HOW TO MAKE PAGES FOR A WEB SITE
PROG Advanced Web Apps 4/13/2019 Programming Data Pages Wendi Jollymore, ACES.
Chapter 10 Accessing Database Files
5/6/2019 Session 8.2 Postback, ViewState
MIS 3200 – Unit 6.1 Moving between pages by redirecting
Button Web Server Controls
Retrieving information from forms
Presentation transcript:

PROG11044 - Advanced Web Apps 2/24/2019 Session 9.2 Data Binding Wendi Jollymore, ACES

Review Repeater control A control that repeats a set of controls and/or formatting You define what each row should look like <ItemTemplate></ItemTemplate> The control is bound to a data source The template is repeated for each set of data E.g. for each element of an array or hash table 2/24/2019 Wendi Jollymore, ACES

Review Repeater.DataSource property Repeater.DataBind() method Contains the name of or reference to a data source E.g. the name of a hash table, the name of an array variable, or the name of a DataSet object Repeater.DataBind() method Retrieves the data from the data source and re-populates the control with that data DataSource and DataBind() are common to the various data-bound controls in ASP.NET E.g. DataList, GridView, FormView, etc. 2/24/2019 Wendi Jollymore, ACES

Review Container.DataItem Refers to a data item in the container (template, in this case) Depends on the source of the data E.g. if the source is an array of strings, then DataItem is a String E.g. if the source is a hash table, then DataItem is one element of the hash table 2/24/2019 Wendi Jollymore, ACES

Review DictionaryEntry class Models a piece of data with a key/value pair Example: A hash table element Key property that contains the key portion Value property for value 2/24/2019 Wendi Jollymore, ACES

Review Container.DataItem from a hash table: We need to get the element’s key and value Cast Container.DataItem into a DictionaryEntry object DictionaryEntry.Key DictionaryEntry.Value 2/24/2019 Wendi Jollymore, ACES

Review Inline data binding expression: <%# … %> .Key or .Value <%# ((DictionaryEntry)Container.DataItem).Key %> <%# … %> Special inline syntax for data binding expression ((DictionaryEntry)Container.DataItem) Cast Container.DataItem into DictionaryEntry object .Key or .Value Reads the key or value property of the hash table element 2/24/2019 Wendi Jollymore, ACES

Repeater Templates ItemTemplate AlternatingItemTemplate The template for each item in the repeater You can put HTML, text, inline code, and other controls in here AlternatingItemTemplate You can make every other row look different E.g. different background colour 2/24/2019 Wendi Jollymore, ACES

Repeater Templates HeaderTemplate FooterTemplate The header! What appears once at the top of the repeater FooterTemplate The footer! What appears once at the bottom of the repeater For more templates, see the DataList control 2/24/2019 Wendi Jollymore, ACES

Repeater Templates Try it out! Make up a hash table with key/value data E.g. myData[“prog10082”] = “OOP 1”; Create a repeater control Header  open table tags and header row of table Footer  add footer row and closing table tags Continued… 2/24/2019 Wendi Jollymore, ACES

Repeater Templates ItemTemplate: Opening and closing <tr></tr> tags Two sets of <td></td> tags First cell for key Second cell for value <ItemTemplate><tr><td>…</td> <td>…</td></tr></ItemTemplate> 2/24/2019 Wendi Jollymore, ACES

Repeater Templates AlternatingItemTemplate Just like ItemTemplate Add to <tr>: bgcolor=“silver” Or whatever colour you like Everything else is the same 2/24/2019 Wendi Jollymore, ACES

Repeater Templates Data binding expression to go inside first set of <td></td>: <%# ((DictionaryEntry)Container. DataItem).Key %> Data binding expression to go inside second set of <td></td>: DataItem).Value %> 2/24/2019 Wendi Jollymore, ACES

Don’t forget to add using System.Collections; Binding the Repeater Page Load event: If this is not a postback, do these things: Create your hash table (just hard-code it) Assign your hash table object variable to the repeater’s DataSource Invoke repeater’s DataBind() Don’t forget to add using System.Collections; 2/24/2019 Wendi Jollymore, ACES

Binding to XML Data Make up an XML File: <bookmarks> <siteName></siteName> <url></url> </bookmark> … </bookmarks> Add new XML to project. Fill in data with whatever sites you want. 2/24/2019 Wendi Jollymore, ACES

DataSets System.Data.DataSet class A cool way to store data in rows and columns DataSet.ReadXml(“xmlFile.xml”) Reads in a valid XML file Stores XML data in a table Will use the XML element names as column names Each <bookmark></bookmark> node will be one record 2/24/2019 Wendi Jollymore, ACES

DataSets from XML Files The data is stored in rows or records The XML element names become the column/field names siteName url “Terminal Learning” http://www.TerminalLearning.com “Pogo” http://www.pogo.com “Bookcrossing” http://www.bookcrossing.com 2/24/2019 Wendi Jollymore, ACES

DataSets from XML Files Make a new project: Add a repeater control and set up a header and item template Header should say “Bookmarks” and formatted however you like Item template contains a single hyperlink server control The link will be an actual link to each bookmark entry in your XML file 2/24/2019 Wendi Jollymore, ACES

Data Binding Expression Eval() method An alternate way of data binding Much more efficient Great to use if you have field names! <%# Eval(“[fieldName]”) %> If you know the name of the data field For the hyperlink control: Add attribute NavigateUrl=‘<%# Eval(“[url]”) %>’ Text between tags: <%# Eval(“[siteName]”) %> 2/24/2019 Wendi Jollymore, ACES

DataSets from XML Files Code: Using System.Data; Page Load: All this is done if this is not a postback Create a new DataSet object Read the XML file into the data set DataSet myData = new DataSet(); myData.ReadXml(MapPath(“bookmarks.xml”)); MapPath() just makes sure you’re using the application path 2/24/2019 Wendi Jollymore, ACES

DataSets from XML Files Page Load, continued Assign the data set object to the repeater’s DataSource Invoke repeater’s DataBind Try loading the page… 2/24/2019 Wendi Jollymore, ACES

Exercise Do the Data Binding tutorial in the notes Very similar to previous two exercises Adds some functionality with check boxes! Note the little blue box about formatting! That’s a hint for Assign 1 2/24/2019 Wendi Jollymore, ACES