1. Prog3 Try and Catch Testing 2 Catching Database Errors Protected Sub DetailsView1_ItemDeleted( sender As Object, e As DetailsViewDeletedEventArgs)

Slides:



Advertisements
Similar presentations
MS-Access XP Lesson 1. Introduction to MS-Access Database Management System Software (DBMS) Store data in databases Database is a collection of table.
Advertisements

1 CS 3870/CS 5870: Lab4 Save with Invalid Price Keep Order After Updating.
Mark Dixon Page 1 20 – Web applications: Writing data to Databases using ASP.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 9 Using the SqlDataSource Control. References aspx.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Mark Dixon Page 1 24 – Object Oriented Programming in ASP.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
Mark Dixon 1 22 – Web applications: Writing data to Databases using ASP.Net.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using ASP.
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.
Internet Technologies and Web Application Web Services With ASP.NET Tutorial: Introduction to.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
1 CS 3870/CS 5870: Note 11 Authentication and Authorization Membership Provider.
Caching Chapter 12. Caching For high-performance apps Caching: storing frequently-used items in memory –Accessed more quickly Cached Web Form bypasses:
1 CS 3870/CS 5870 Note04 Session Variables and Post Back.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
1 CS 3870/CS 5870: Note 13 Lab 6 Authentication and Authorization Roles Management.
Damian Tamayo Tutorial DTM Data Generator Fall 2008 CIS 764.
1 CS 3870/CS 5870: Note 07 Lab 3 Lab 4 Test 1: Two Tables.
Chapter 16: Programming Structures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP.
Senior Elective Tutorial MS Access Database: Student Records.
1 CS 3870/CS 5870: Note05 Prog3 Web Application with Database.
Chapter 16: Programming Structures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState.
1 CS 3870/CS 5870: Note 20 Web Service. 2 What is Web Service? Providing functionality online to other applications, Web and Windows applications. The.
1 CS387/CS587: Note 08 Shopping Bag DataTable. 2 DataClass Public Shared Function NewShoppingBag() As Data.DataTable Dim bag As New Data.DataTable bag.Columns.Add("Product.
1 CS387/CS587: Note05 Lab 3. 2 Global.asax Must not be under any sub-folder Application_Start Application_End Application_Error Session_Start Session_End.
Mark Dixon 1 22 – Object Oriented Programming. Mark Dixon 2 Questions: Databases How many primary keys? How many foreign keys? 3 2.
1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Editing and Designing Databases.
1 CS 3870/CS 5870: Note 16 Web User Controls. Prog 7 Copy Prog6 to Prog7 Modify all files for Prog7 Remove Web.config from sub-folders Make sure Prog7.
1 CS387/CS587: Note04 Lab 3. 2 Master Page All Web pages will be similar Should be created before other web pages Add New Items Controls on the Master.
1 CS 3870/CS 5870: Note 13 Web Service. 2 What is Web Service? Providing functionality online to other Web applications SOAP Simple Object Access Protocol.
31/01/ Selection If selection construct.
1.NET Web Forms Applications: Main Form © 2002 by Jerry Post.
1 CS 3870/CS 5870: Note 14. Prog5 Due 10 PM Wednesday, Oct 21 Authentication and Authorization 2.
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.
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.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
E-Commerce: Introduction to ASP.Net Application Architecture 1 Dr. Lawrence West, Management Dept., University of Central Florida Topics.
Processing multiple files
Use TryParse to Validate User Input
ASP.NET Programming with C# and SQL Server First Edition
CS 3870/CS 5870 Web Service.
A variable is a name for a value stored in memory.
Unit 9.1 Learning Objectives Data Access in Code
Stored Procedures Dr. Ralph D. Westfall May, 2011.
Web Application with Database
CS 3870/CS 5870 Web User Controls.
SQL and SQL*Plus Interaction
Session Variables and Post Back
Source file containing the data (Spreadsheet or Database)
Database application MySQL Database and PhpMyAdmin
3.01 Apply Controls Associated With Visual Studio Form
Computer Programming I
Use TryParse to Validate User Input
Web Application with Dataase
3.01 Apply Controls Associated With Visual Studio Form
Exception Handling.
Unit 27 - Web Server Scripting
CS 3870 Prog6 Roles Management Due Monday, November 5 Group Assignment.
CS 3870/CS 5870 Web User Controls Events (II).
Exception Handling.
Adding Record To Your Database
CS 3870/CS 5870 Test 2 (50 points) Thursday
Web Application with Dataase
Active server pages (ASP.NET)
Updating Databases With Open SQL
Updating Databases With Open SQL
Presentation transcript:

1

Prog3 Try and Catch Testing 2

Catching Database Errors Protected Sub DetailsView1_ItemDeleted( sender As Object, e As DetailsViewDeletedEventArgs) Handles DetailsView1.ItemDeleted If Not e.Exception Is Nothing Then e.ExceptionHandled = True txtMessage.Text = e.Exception.Message End If End Sub Not DetailsView1.ItemDeleting! 3

Accessing Controls on Master Page From ASPX page –Design View: OK –Source View: OK –May need to type 4

Accessing Controls on Master Page From VB file? –Property Master Dim db As SqlDataSource = Prog4MasterPage.getDataSource() On Master Page –Make a public function or property to return the control Public Function getDataSource() As SqlDataSource Return SqlDataSource1 End Function 5

Accessing Controls on Master Page You can use a Shared public function or use a Shared variable ‘ Prog4MasterPage Public Shared myDataSource As SqlDataSource Protected Sub Page_Load(...) Handles Me.Load myDataSource = SqlDataSource1 End Sub ‘ Page Updating Dim db As SqlDataSource = Prog4MasterPage.myDataSource 6

Page Default When visiting the page the first time, the first page is displayed. On any following visits, the page displayed last time should be displayed. Must use Session variable Checking IsPostBack in Page_Load 7

Page Updating When visiting the page later from other pages, the record previously displayed should still be shown on the form. Must use Session variable Form Load ‘ when not post back DetailsView1.PageIndex = Session("Prog4_RecordIndex") DetailsView1.PageIndexChanged Session("Prog4_RecordIndex") = DetailsView1.PageIndex 8

Prog 4 The new inserted record will still be displayed on the form after saved back to the database, and clicking on Next, Previous, First, and Last will show the correct record based on ProductID. 9

Protected Sub DetailsView1_ItemInserted(...) Handles DetailsView1.ItemInserted If e.Exception Is Nothing Then ‘ Completed ‘ find the index of the new added record ‘ modify DetailsView1.PageIndex Else ‘ failed End If End Sub 10

Protected Sub DetailsView1_ItemInserted(...) Handles DetailsView1.ItemInserted... ‘ find the index of the new added record... End Sub Protected Sub DetailsView1_ItemInserting(...) Handles DetailsView1.ItemInserting ' save the new ID Session("Prog4_NewID") = e.Values(0) End Sub 11

Dim dv As System.Data.DataView = SqlDataSource1.Select(DataSourceSelectArguments.Empty) Dim index As Integer = 0 For index = 0 To dv.Count - 1 Dim id As String = dv(index)(0) If id = Session("Prog4_NewID") Then Exit For End If Next DetailsView1.PageIndex = index 12 If SqlDataSource1 is on the Page

Dim db As SqlDataSource = Prog4MasterPage.myDataSource Dim dv As System.Data.DataView = db.Select(DataSourceSelectArguments.Empty) Dim index As Integer = 0 For index = 0 To dv.Count - 1 Dim id As String = dv(index)(0) If id = Session("Prog4_NewID") Then Exit For End If Next DetailsView1.PageIndex = index 13 If SqlDataSource1 is on the Master Page

Dim db As SqlDataSourdim db as sqldatasourcece = Prog4MasterPage.myDataSource Dim dv As System.Data.DataView = CType( db.Select(DataSourceSelectArguments.Empty), System.Data.DataView) Dim index As Integer = 0 For index = 0 To dv.Count – 1 ‘ Must Trim to handle ID with less than 3 chars Dim id As String = dv(index)(0).Trim If id = Session("Prog4_NewID") Then Exit For End If Next DetailsView1.PageIndex = index 14

Prog 4 The new inserted record will still be displayed on the form after saved back to the database, and clicking on Next, Previous, First, and Last will show the correct record based on ProductID. Using SQLDataSource Controls 15

How to Do it Using SqlDataClass? The new inserted record will still be displayed on the form after saved back to the database, and clicking on Next, Previous, First, and Last will show the correct record based on ProductID. Using SQLDataClass procedure? –Load table (otherwise at the end) –Find the index –DisplayRow 16

Test 1 Thursday, Oct 8 Lab 206 2:00 – 4:00 50 points 17

Test 1 CSS Files Nested Master Pages Post Back Session Variables Accessing Database Formatting Checking Input and Catching Errors 18