Download presentation
Presentation is loading. Please wait.
Published byCorey Green Modified over 9 years ago
1
1 CS 3870/CS 5870: Note07 Prog 4
2
Master Pages Creating a master page based on another master page MainMasterPage –For all Progs and Tests Prog4MasterPage –For Prog 4 only 2
3
Main Master Page Head –Title: UWP – CS 3870/CS 5870 –ContentPlaceHolder with ID “head” (“MainHead”) –Link to CSS file Body –Form –H1: Web Protocols... –H2: Names –ContentPlaceHolder with “ContentPlaceHolder1” (“MainBody”) 3
4
Creating a Master Page Based on Another Master Page Adding New Master Page –Add New Items –Master Page –Select master page –Place code in separate file Master Page (with master) 4
5
Prog4MasterPage No head or body or form –All are in MainMasterPage Content for “MainHead” –What can be added here? –CSS file link Content for “MainBody” –All controls should be within this Content –Add a new ContentPlaceHolder using ToolBox (“Prog4Body”) –Individual content pages CANNOT access “MainBody” directly 5
6
Prog4MasterPage TreeView –Inside Content MainBody –Not completed 6
7
Content Pages Add New Items –Web Form –Select Master Page –Place code in separate file –Default.aspx Add Web Form (with master) –Updating.aspx –Shopping.aspx 7
8
Content Pages Content for Prog4Body –All controls should be within this content control Cannot access MainBody of MainMasterPage directly 8
9
Prog4MasterPage Complete TreeView on Prog4MasterPage –Source view –Design view 9
10
10 TreeView Controls Navigation Tab Property Nodes (Collection) –Root Nodes –Child Nodes –Node Properties Text NagivateUrl
11
11 Accessing Database Data Source Controls –SqlDataSource –AccessDataSource –... Code class –Connection –Command –DataAdpater –AdapterBuilder Prog 3: Use Code class Prog 4: Use Data Source Controls
12
Page Default.aspx SqlDataSource GridView Format GridView –Auto Format –Edit Columns –UnitPrice 12
13
Page Updating and Shopping Each page needs one SqlDataSource. Can we use just one SqlDataSource? Where should it be? 13
14
One SqlDataSource on Prog4MasterPage 14
15
SqlDataSource Data Tab on ToolBox Smart Tag –Configure Data Source New Connection –Server Name: Xray\Sqlexpress –User SQL Server Authentication –User name: jim –Password: UWPCS3870 (case sensitive) –Select or enter a database name: UWPCS3870 (case sensitive) –Test Connection (again) –OK Next 15
16
SqlDataSource Yes, save this connection as Specify columns from a table or view –Product –Where –Order By… –Advanced Generate Insert, Update and Delete statements: Check Use optimistic concurrency: Check –Next Test Query Finish 16
17
Data Bound Controls Data Tag GridView FormView DetailsView DataList ListView... 17
18
Page Default Must use GridView Read Only Must Format Fields 18
19
Choosing Data Source: GridView SqlDataSource on the same page –Selecting the items SqlDataSource on the master page –Smart Tag of GridView –Type value for DataSourceID –Design View –Source View –Properties Window 19
20
Format GridView Smart Tag of GridView AutoFormat –Your choice Edit Columns Uncheck “Auto-generate dields” Add BoundField –Type value for Data Field –Header Text –ItemStyle –DataFormatString 20
21
GridView Enable Paging: Yes Enable Sorting: Yes Enable Editing: No Enable Deleting: No Enable Selecting: No 21
22
Paging GridView Property Window Page size: 5 Page Settings –Mode: NextPreviousFirstLast –Text: Next, Previous, First, Last 22
23
Paging GridView: Source View –Design View –Source View –Properties Window 23
24
Page Updating Any Data Bound Control One record at a time Navigate to all records Sorted by ProductID Update Delete New Message textbox 24
25
Paging DetailsView Property Window Page Settings –Mode: NextPreviousFirstLast –Text: Next, Previous, First, Last 25
26
Format DetailsView Auto Format Edit Fields Same as GridView 26
27
Editing Records Edit Save Cancel ID: Read Only 27
28
Insert New Record 28
29
Deleting Record Does it Work? 29
30
Prog4MasterPage Source View SqlDataSource –DeleteParameters –Only need one parameter <asp:Parameter Name="original_ProductID" Type="String" –Remove other parameters 30
31
Test 1 Thursday, October 8 31
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.