ASP'NET 2'0 - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

ASP'NET 2'0

Description:

DataBinding may include a DataSource control, but that ... XPath finds a tag named pubDate in the XML. 9/5/09. DataBinding. 24. Configuring the XmlDataSource ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 25
Provided by: donba5
Category:
Tags: asp | net | pubdate

less

Transcript and Presenter's Notes

Title: ASP'NET 2'0


1
ASP.NET 2.0
  • DataBinding

2
DataBinding
  • The term DataBinding refers to tying the value of
    something to a source of values for that thing.
  • DataBinding may include a DataSource control, but
    that need not be the case in every circumstance.
  • DataBinding may be one-way or two-way.
  • One-way data-binding assigns source value to a
    property of a control. Later changes in the
    control will not change the source value.
  • Source ? bound-property of the control
  • Two-way data-binding allows for the possibility
    that later changes in the value of the control
    will be reflected back in the data source
    (consider a database update operation as an
    example).
  • Source ? control

3
DataBinding
Database, sitemap, or other data provider
These give 2-way DataBinding.
4
DataBinding
Note we have commands for Selection (one-way
binding) and for Update, Delete, and Insert
(two-way binding)
Default mode is edit (2-way binding)
5
DataSources and DataBinding
  • The use of SqlDataSources with GridViews,
    DetailsViews, and FormViews is a form of
    DataBinding.
  • The use of SiteMapDataSources with Menus,
    TreeViews, and so forth is DataBinding.
  • The DataBinding done so far is pretty vanilla.
    It may be customized through the use of
    parameters.

6
Parameters in DataBinding
7
Parameter Example
  • If we have a GridView and would like to see a
    DetailsView of the row selected in the GridView,
    we need to tie the data source for the
    DetailsView control to the selected item in the
    GridView.
  • A parameter will help us in doing this.

8
Parameter Example
GridView showing page of rows from database
DetailsView of the Selected row from GridView
DataSource is entire table of a database
DataSource must be just selected row of the table
9
Configuring GridView DataSource
10
Configuring GridView DataSource
Note all fields selected when we dragged table
from Server Explorer to the form.
DB Table name
Select the fields you want
Generated Select SQL statement
11
Configuring GridView DataSource
We can Test the Query before we accept the
configuration.
Actual live data from table
12
Configuring the DetailsView
Not the same DataSource as GridView we dont
want the whole table
13
Configuring the DetailsView
Use same connection string because we want to use
the same database
14
Configuring DetailsView
Same table and columns, but we want only the
selected row from GridView
15
Configuring DetailsView
Select the Primary Key column (so it has a unique
value)
16
Configuring DetailsView
Choose the operator (i.e., we want the ID
value in the Details View to be the ID of the
selected row in the GridView
Select Control because the selected row of the
GridView control is what we want to match
17
Configuring DetailsView
SQL Where Clause being generated
Select the control we want to match
The parameter to match
18
Final Where Clause
Value of Parameter
Click Add then OK
19
Test It and Finish
20
Viewing Resulting Web Page
21
XmlDataSource
  • An XML data source is a file that may be an
    actual file in some folder or a file of XML
    received from a web service such as an RSS feed.
  • Following is an example of an RSS feed reader
    no-code program.
  • To illustrate this, the empty code-behind file
    has been removed from the project.
  • See solution explorer

22
RSS Feed Reader Example
23
RSS Example Edit Templates
XPath finds a tag named pubDate in the XML
24
Configuring the XmlDataSource
Finds an item tag inside a channel tag inside an
rss tag
Write a Comment
User Comments (0)
About PowerShow.com