4.63 out of 5
4.63
97 reviews on Udemy

A Gentle Introduction To ASP.NET Web Forms For Beginners

Creating Dynamic Websites .... A First Step
Instructor:
Charlie Chiarelli
406 students enrolled
English [Auto-generated]
Create simple multi-page ASPNET web applications incorporating a number of server controls
Incorporate field validators to check for errors
Pass data between pages
Work with style sheets and master pages
Create database driven web pages by adding a SQL server database or Access database
Work with the concept of Databinding by adding databound controls to a Web Form
Perform CRUD operations on dynamic data from an SQL Server database.

There are a number of  flavors of ASP.NET,  for example,  Web Forms (Web Sites and Web Applications),  Model-View-Controller (MVC) and the newest one Core. This course is aimed at anyone who wants to create dynamic websites with ASP.NET Web Forms. ASP.NET is the Microsoft platform for developing Web Applications. Using ASP.NET you can create e-commerce sites, data driven portals and just about anything else you can find on the internet. Best of all, you don’t need to paste together a jumble of HTML and Script code. Instead you can create full scale web apps using nothing but code (C#) and a design tool like Visual Studio.

In recent years Microsoft has added MVC(Model View Controller) and Core which offer different ways to build dynamic web pages. To some MVC and Core are cleaner and more suited to the web. To others it’s a whole lot of extra effort with no clear payoff. Either way, you need a strong knowledge of basic ASP.NET before moving onto the newer technologies.

Here’s how I will help you to succeed:

o    Each lecture starts with a list of objectives/speaking notes

o    Every example covered in the lecture is available for download in the resources section  … including the objectives/speaking notes

o    Almost every lecture has a set of Practice problems with full solutions provided

o    My style of writing and teaching follows the KISS principle : Keep It Super Simple.   I try to stay away from fancy computer terminology and try to teach like am speaking to a brand new user with little to no previous knowledge on the subject matter…. and  I am always available for help … replying most times within a day.

Course Information

1
Welcome

In this Lecture we will 

  • Learn about the instructor for this course ... Charlie Chiarelli

    • Retired Highschool Computer Science Teacher with over 35 years experience

    • Online instructor for the past 10  + years

    • Udemy instructor for the past 4 years

    • 4th course on Udemy

      • Other course are all C# based

      • Beginners C#

      • Intermediate C#

      • Developing Games in C#

  • Learn about the Aim of the Course

    • What you will learn ( ASP.NET for true beginners)  and what you won't (no ASP.NET Core)

  • Highlight some Helpful Skills to have

    o    Beginners knowledge of C#

    o    Basic understanding of how a web page is created with HTML

    o    Some knowledge of CSS will help but is not required

  • Discuss what you need to succeed… a philosophy

  • Highlight some of the ways this course will help you succeed

    o    Each lecture starts with a list of objectives/speaking notes

    o    Every example covered in the lecture is available for download in the resources section  … including the objectives/speaking notes

    o    Almost every lecture has a set of Practice problems with full solutions provided

    o    The instructor is available for help … replying most times within a day

2
Why ASP.NET ... Some Background

In this Lecture we will 

  • Take a look at the Big picture ... The Evolution of Web Development

    • Basic HTML

    • HTML Forms ... introduction of tags for textboxes and buttons

    • Server Side (PHP ... Hypertext Preprocessor  /ASP.NET ... stands for Active Server Pages) 

    • Client Side Programming (Javascript)

    • Static vs Dynamic Content

      • Static Content

        • Typically HTML (.htm) files return the same thing each time requested

        • Updates to content require updating the html file

      • Dynamic content

        • ASP.NET Web Forms (.aspx) can contain dynamically generated content

        • No need to update .aspx files for new content

        • all code runs on the web server the final result is sent back to the client as ordinary HTML

          Content typically drawn from other sources like a database

  • Learn what does ASP.NET do for us?

    • ASP.NET is the Microsoft platform for developing Web Applications. ASP.NET is part of the larger Microsoft .NET framework. C#, is another component.

    • It allows us to create dynamic websites using server web controls and applications. 

      • Dynamic websites allow users to query databases in real time rather than loading static pages on each interaction

      • Using ASP.NET you can create e-commerce sites (like Amazon.com) , data driven portals and just about anything else you can find on the internet.

  • Learn there are a number of  flavors of ASP.NET,  for example,  Web Forms (Web Sites and Web Applications),  Model-View-Controller (MVC) and the newest one Core. This course is aimed at anyone who wants to create dynamic websites with ASP.NET Web Forms.   Best of all, you don't need to paste together a jumble of HTML and Script code. Instead you can create full scale web apps using nothing but code (C#) and a design tool like Visual Studio.

    MVC(Model View Controller) and Core offer different ways to build dynamic web pages. To some MVC and Core are cleaner and more suited to the web. To others it's a whole lot of extra effort with no clear payoff. Either way, you need a strong knowledge of basic ASP.NET before moving onto the newer technologies.


3
What You Need

In this Lecture we will

  • Highlight the software you need to participate in the course
    • Visual Studio 2017  Community
    • 7zip
4
What You are Going to Learn

In this Lecture we will

Learn about some of the concepts and applications we will create ..  a sampling of web applications

Introduction to ASP.NET

1
How Dynamic Web Sites Work

In this Lecture we will

  • Learn how the Web Server handles requests for Web Pages (Internet Information Server IIS)
  • Learn about the Application Server (usually built into the Web Server)
    • this is the part that understands the code/types: ASP.NET/PHP
  • Learn about the Database Server
    • SQL/MySQL/Access (only supports a few simultaneous users)
  • Learn about how the application server processes the code and sends a complete HTML page back to the Web Server which in turn sends that on to the page
2
Dynamic Web Site Development Intro Quiz

Recap of the introduction to Dynamic Web Site Development

3
Getting Started using Visual Studio...Creating a Simple Web Application

In this Lecture we will

  • We acquaint ourselves with the Visual Studio IDE by creating a simple  ASP.NET Web Application IntroToVSandASPNETwebapps

    • choose empty website ... add folders and core references for Web Forms

    • this creates a nearly empty site with a stripped down web.config

    • you fill in pieces as needed... manually adding a web form (default.aspx)

    • best starting point because you won't have any extra unnecessary generated files

    • add an image folder (in solution explorer pane)... then copy image files directly there.

    • design and source view

  • Learn to add text to the web page and format using Headings (H1...H6)

    • note: if you center text all objects center, put in <p> to center only that specific text

  • Learn to add images to a web page using a number of methods

    • drag and drop

    • HTML <IMG> control

  • Learn to edit in source view with Intellisense 

    •  add <br /> 

    • uses XHTML rules 

  • Learn to title pages

    • in properties

    • choose <DOCUMENT> then modify title

  • Learn to view page in browser

4
HTML vs ASP.NET

In this Lecture we will

  • Discuss the differences between HTML and ASP.NET controls

    • HTML loads faster ... better for static pages

    • ASP.NET controls must constantly interact with server

    • HTML button control is coded in Javascript

      • when you double click on it, you are put into HTML source onClick event

      • you then must provide the code for the corresponding function eg. alert("Welcome");

    • ASP.NET button control is coded in C# ... when you double click on it creates Event Handler

      • code behind file ... aspx.cs

  • Create a simple ASP.NET Web application that uses ASP.NET and HTML controls and incorporates C# coding  (enter a name and display a greeting) MyFirstWebApp

    • using labels,text boxes and button controls

    • add HTML elements .... <HR> from the HTML controls in toolbox

    • format text eg. font, color (CSS based) SimpleFormatting

      • uses classes (internal style sheet)

      • converts text to hyperlink (Format menu)

      • adds an ASP.NET image control

    • Visual Studio has a built-in viewer for ASP.NET pages you create... BUT

      • You can't just open a dynamic page on your own computer (without VS) before it is posted online as you can a regular HTML page.

      • You must view a dynamic page through a Web Server that has an appropriate application server running.

      • ASP.NET is the server model we use. It runs in conjunction with Microsoft IIS Web Server .. http://localhost

    • Discuss the difference between server side code and client side code (view source in browser)

      • Default.aspx (server-side) ... runat="server" tells Webserver that ASP.NET tags should be processed before sending page to the browser

      • Default.aspx(client-side) ... browser gets HTML generated by ASP.NET

5
HTML vs ASPX Quiz
6
Creating a Multi-Page Web Application

In this Lecture we will

  • Create a 2 page web site using web forms MultiPage
    • add a hyperlink that goes to the 2nd page using a number of techniques
      • highlight text then click the link button on the toolbar
      • drag the page to link right onto the 1st page then change the <a> tag
    • change the start page of the site
    • add code to the Page_Load event to indicate "morning" or "night" using the DateTime.Now.Hour command ... makes the site a little dynamic
  • Offer you an exercise to practice the skills you learned in this lecture


Creating Web Forms ... A Detailed Look

1
ASP Server Controls Part 1

In this Lecture we will

  • Reinforce the idea that a Web Application can contain HTML and ASP.NET server controls

  • Learn to use a number of new controls including

    • radiobuttons

      • use the property group name for related radiobuttons

    • checkboxes

    • dropdownlists

      • set autopostback to true

    • image control 

      • ImageUrl property ... /images/name.jpg

  • Create several programs to illustrate the concepts above

    • MoreControls

    • TeamMemberBios

  • Challenge you to create your "own" TeamMemberBios site

2
ASP Server Controls Part 2

In this Lecture we will

  • Recap the use of RadioButtons  and C# If Statements Conditionals

  • Learn how to use the checkboxList ... note the use of <br /> html tag

    • Simple example picking pizza toppings (pre-cursor to Practice Problem)

    • foreach(ListItem x in CheckboxList1.Items)

      • if (x.Selected==true)

        • Label1.Text+="You picked " + x.Value + "<br />";

  • Practice what we have learned by creating the "Pizza Store" Web Application

3
Field Validators

In this Lecture we will

  • Look at the concept of field validation

    • required field validator

    • range validator

    • regular expression validator

    • need to add lines below to web.config for validation controls to work in newest VS Editions

      • <appSettings>

        <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>

        </appSettings>

  • Create a program to illustrate the concepts above

    • ValidatedCustomerForm

4
Intro to ASP.NET Server Controls Quiz
5
Using Methods in C# ... Some Mathematical Web Applications

In this Lecture we will

  • Acquaint or reacquaint ourselves with the concept of methods and why they are used

    • A method is a code block that contains a series of statements. A program causes the statements to be executed by calling the method and specifying any required method arguments

    • Methods can make programs/web applications more efficient by centralizing similar code blocks in one block and can be re-used wherever necessary

  • Look at the two types of methods 

    • void type

    • types that return values

  • Introduce the use of the C# TryParse built-in methods

  • Create several programs to illustrate the use of methods in web applications

    • HelpMethod

    • PostalCalculator

6
The Calendar Server Control and Working with Dates

In this Lecture we will

  • Take a close look at the calendar control and how to implement it in a web application

    • get dates

    • set dates

    • determine number of days between dates

    • restrict dates

  • Create several programs to illustrate these calendar concepts

    • Calendar

    • DaysBetweenDates

    • TheCalendar

7
The Concept of Postback

In this Lecture we will

  • Discuss the Post Back problem ... Demo with ThePostBackProblem

    • PostBack is the name given to the process of submitting an ASP.NET page to the server for processing.

    • every post back reloads web page .... re-executes Page_Load (this is where we could run into problems)

    • to check for post back use the command IsPostBack

    • in Page_Load ... add

      • if (Page.IsPostBack==false) ... checks to see if page loaded for first time or not

  • Create a program to illustrate the use of PostBack

    • CheckBoxTest

  • Offer you the challenge to create a ASP.NET Web Application highlighting your favorite musical band/sports team 

    • which displays a message on opening

    • on subsequent requests band/team member info is displayed

    • TeamMemberBiosPostBack

8
Event and PostBack Quiz
9
Navigating Between Pages and Passing Data To Another Page

In this Lecture we will

  • Review and extend our techniques to move between web pages (NavBetweenPages/QueryStringExample)

    • Hyperlink Text  via HTML

    • Hyperlink an Image via HTML

    • Use the ASP.NET server control Hyperlink (Text and Images)

    • Use a  LinkButton  and regular Button to navigate to another page via code in the button event handler

      • Response.Redirect("page.aspx");

  • Learn how to pass data to another page

    • introduce the concept of a query string ... observe a Google search query

    • look at the query string format : ?h1=en & q=web & btnG=Google

    • use Response.Redirect("file.aspx" + QueryString)

    • use Request.QueryString["passingvariable" ]

  • Look at the concept of Session Variables

    • here values are not passed via Response.Redirect in query string  ... variables are private

      • Session["pw"] = TxtPass.Text  (on login page)

      • TxtDisplay.Text=Session["pw"].ToString()  on new page

      • Can send user back to login screen for invalid entry

      • Remember to set TextMode to Password for Password TextBox

  • Offer you the challenge of creating a multi-page site with

    • a main login page

    • a second page highlighting your favorite team/musical group

10
Challenge Problem #1 ... Casino Slots

In this Lecture we will

  • Offer you the challenge of creating a simple slots game having 3 windows

  • Provide a fully detailed solution after you give it a try ... CasinoSlots

    • illustrates use of arrays

    • illustrates use of TryParse

    • illustrates use of Methods

    • illustrates use of Image.ImageUrl

11
Challenge Problem #2 ... Currency Converter

In this Lecture we will

  • Offer you the challenge of creating a Currency Converting web page
  • Provide a fully detailed solution after you give it a try
    • illustrates use of IsPostBack
    • illustrates use of DropDownList
    • illustrates use of Decimal.TryParse
    • illustrates use of accessing CSS attributes through a style collection
      • controlName.Style["AttributeName"]="AttributeValue"
12
Challenge Problem #3 ... Birthday Card Maker

In this Lecture we will

  • Offer you the challenge of creating a simple birthday card maker
  • Provide a fully detailed solution after you give it a try
    • illustrates the use of a panel containing a label and an image control
    • illustrates the use of FontUnit.Point
    • illustrates the use of Font.Name

Working with Style Sheets and Master Pages

1
Creating and using Style Sheets Part 1

In this Lecture we will

  • Learn about the advantages of using Styles

    • If you want your Web site to have a unique character and be easy for visitors to get around in, it’s important to maintain a consistent look and feel throughout all pages in your site. This involves thinking about what kinds of design elements you might use in your site. Examples of design elements include things like main headings, subheadings, body text, tables, picture borders, lines, and other items that might appear on pages throughout your site.

    • To maintain a consistent look and feel, it’s best to predefine the exact appearance of all these items in style sheets. Doing so up front saves you a lot of time because you don’t have to style every single heading, table, and picture as you add it to your page. Instead, you just format things normally and they automatically take on the appropriate appearance as you create them.

    • The real beauty of style sheets goes beyond consistency and ease of use to, well, preserving your sanity. If you ever decide to change the style of some element in your Web site, you don’t have to go through every single page and make the change. You just change the style in the style sheet, and the new style is automatically displayed in every page. The technology you use to create style sheets goes by the name Cascading Style Sheets, or CSS for short.



  • Learn about the three types of CSS

    • In a separate file (external)

    • At the top of a web page document (internal)

    • Right next to the text it decorates (inline)


    External style sheets are separate files full of CSS instructions (with the file extension .css). When any web page includes an external stylesheet, its look and feel will be controlled by this CSS file (unless you decide to override a style using one of these next two types). This is how you change a whole website at once. And that's perfect if you want to keep up with the latest fashion in web pages without rewriting every page!

    Internal styles are placed at the top of each web page document, before any of the content is listed. This is the next best thing to external, because they're easy to find, yet allow you to 'override' an external style sheet -- for that special page that wants to be a nonconformist! (see SimpleFormattingRevisited)

    Inline styles are placed right where you need them, next to the text or graphic you wish to decorate. You can insert inline styles anywhere in the middle of your HTML code, giving you real freedom to specify each web page element. On the other hand, this can make maintaining web pages a real chore!


  • Learn how to create different types of Style Sheets using the Style Builder (Under Format menu)

    • Inline Styles (StyleSheetIntro)... use Style Builder and define in current page ... click inside <div>

      • we take a simple page containing  some text, a text box and a button and create a style to improve the look

        • we add a background color, border,  border color

        • we change the default font and size and style (italic)

      • we update and edit the style using the CSS properties window

        • View/CSS properties

        • View/Manage Styles

    • External Styles (linking to an external Style Sheet file) (ExternalStyleIntro)

      • create a folder called stylesheet

      • right click folder and add new item .. StyleSheet (give it a name)

      • in design view ...pick New Style (under format menu) then  new/existing file

      • create the style rules in the builder

        • Choose Selector (HTML tag/Class/ID) then Declaration (property:value)

          • we style the <body> tag and the <H1> <H2> tags

          • we create a class

    • Learn how to link to a style sheet

      • drag stylesheet to upper left corner of page

      • to apply a class ... highlight text .. then View/Apply Styles or go to Properties/Class

2
StyleSheets Intro Quiz

Intro Quiz on Web Page formatting using StyleSheets

3
Creating and using Style Sheets Part 2

In this Lecture we will

  • Learn about the style sheet concept of Flow and Floating Based Layout (FlowBasedLayoutIntro)

    • create a style (without floats)  that defines a

      • header

      • left panel

      • center panel

      • right panel

      • NOTE:  we use classes here... but the most correct way to define these specific elements  we learn in our second example using ids

  • Take a look at a more complex Floating Layout (ChiarelliElearning)

    • reviews the concepts of classes, ids , descendent selectors, page wrappers

      • You use IDs when you have a single element on the page that will take the style. IDs must be unique. They are defined with  "#" . Examples of ids are: main-content, header, footer, or left-sidebar.

      • You use a class when you want to consistently style multiple elements throughout the page/site. A class is defined with a "."  Classes are useful when you have, or possibly will have in the future, more than one element that shares the same style. An example may be a div of "comments" or a certain list style to use for related links. Additionally, a given element can have more than one class associated with it, while an element can only have one id. For example, you can give a div two classes whose styles will both take effect.


4
Creating and Using Master Pages

In this Lecture we will

  • Learn about ASP.NET’s master pages feature, which allows you to define page templates and reuse them across your website.

    • Learn that Master pages are similar to ordinary ASP.NET pages. Like ordinary pages, master pages are text files that can
      contain HTML, web controls, and code. However, master pages have a different file extension (.master instead of .aspx), and they can’t be viewed directly by a browser. Instead, master pages must be used by other pages, which are known as content pages. 

    • Learn that essentially, the master page defines the page structure and the common ingredients. The content pages adopt this structure and just fill it with the appropriate content. For example, if a website such as http://www.amazon.com were created using ASP.NET, a single master page might define the layout for the entire site. Every page would use that master page, and as a result, every page would have the same basic organization and the same title, footer, and so on. However, each page would also insert its specific information, such as product descriptions, book reviews, or search results, into this template.

  • Create a  simple Master Pages and apply to a web page (MasterPageIntro)

    • create a folder called master

    • add new item ... Master Page 

      • modify layout ... take a good look at the code in source view

      • moving ContentPlaceHolder into appropriate locations on page ... this will hold unique content on each page that uses master

      • you can drag more ContentPlaceHolders as needed from toolbox or copy and paste in source

    • use the master page

      • create a new web form  ... choose Web Form with Master

      • editing the master page

5
Creating a Master Page using a CSS Template

In this Lecture we will

  • Demonstrate how to incorporate a style sheet into a master page (ChiarelliElearningMasterStyled)

    • use a CSS floating layout 

    • put a Content Placeholder in the "MainContent" ID Section

    • create a web page based on the master page

  • Deriving a master page from a full CSS Template

    • using a freely available template (soft_green) ... copy styles.css and images folder over to Visual Studio 

    • create a master page ... remove the content placeholder from <head> section and <div> from body

    • copy all the <div> content in body of index.html(css template) into body of master page

    • drag style sheet onto master page

    • move content placeholder to appropriate position and add other holders where necessary

  • Demo a master page based on a free CSS Templates

    • BrownShadow -> BrownShadowMod

  • You try modifying this free CSS Templates ... Metamorph

6
Challenge Problem... A Summative Assessment

In this Lecture we will

  • Challenge you with a exercise to practice the skills you learned in this section on using Style Sheets and Master Pages

    •  Find a Free CSS Template and implement it into a site of your own interest ... Sports/Music Group  etc

      • The site should use a Master Page which is then used to create subsequent sub pages of the site 

  • Need Resources ? .... check the links from the previous lecture


Database Driven Web Pages

1
The Concept of Data Binding ... Part 1 Creating an SQL Database

In this Lecture we will

  • Learn that many sites today are dynamic and interactive 

    • They display content that is updated frequently ... news, sports, stocks

    • They allow clients to interact with the site ... shopping sites, auction sites

  • Learn that interaction requires storage

  • Learn that creating a database is a way to solve this storage requirement

  • Demonstrate how Visual Studio can be used to create a database using SQL Express (DataBindingIntro1)

    • local file based database engine ... similar to Access with full SQL support for database up to 4 GB

    • right click on App_Data folder

      • create a new database (Customers) ... note database explorer window now appears

      • add a new table  then add fields and data types

        • customerID ... int /FirstName ... varchar(50) /LastName... varchar(50) /CreditLimit... money

        • varchar means variable length text 1-50 characters

        • set identity specification for customerID and make it a keyfield

      • save table (customer.mdf)

        • edit SQL name from Table to Customer

        • press Update (choose Update Database)

        • go over to Server Explorer and Refresh ... the Customer table should now appear under the table section

      • Now enter data (right click on newly appearing Customer table / show table data)

      • interact with DB using SQL (right click customer table and select new query ... find all customers whose creditlimit is less than $8000 (Don't save query ... just demo results)

        • SELECT FirstName, LastName, CreditLimit FROM Customer WHERE CreditLimit < 8000  

2
The Concept of Data Binding ... Part 2 Adding Databound Controls to a Web Form

In this Lecture you will

  • Learn that the basic principle of data binding is this: you tell a control where to find your data and how you want it
    displayed, and the control handles the rest of the details. 

    • ASP.NET data binding works in one direction only. Information moves from a data object into a control. Then the data objects are thrown away, and the page is sent to the client. If the user modifies the data in a data-bound control, your program can update the corresponding record in the database, but nothing happens automatically. 

  • Learn about many of the most powerful databinding controls, such as the GridView and DetailsView, which give you unprecedented control over the presentation of your data, allowing you to format it, change its layout, embed it in other ASP.NET controls, and so on.

  • Add Databound controls to the Web Form started in the previous lecture (DataBindingIntro2)

    • add a data source to the web form (SqlDataSource)

      • Create a new connection

      • choose Data Source (SQL Server DB) and DB File (customer.mdf)

      • specify columns (*) all ... notice Select statement

      • press Test Query

    • add a grid view to display data ... choose data source SqlDataSource1

      • also demo simple technique ... just drag and drop data table in <DIV> block (IDE adds 2 controls Grid View and SqlDataSource) ... make sure to choose SqlDataSource1

    • add a details view to a new web form 

      • after initial SqlDataSource is added to a web form there is no need to create that connection again. You only need to add the desired control.

      • Visual Studio will automatically add the SqlDataSource after you answer the prompts

        • first drag and drop the DetailsView control

        • next choose new data source ( SQL DB)

        • to the left of "New Connection" pick from the drop down menu "ConnectionString"

        • Now you are accessing the previous data source

        • choose your columns and test your query

      • autoformat 

      • enable paging

      • ... other properties (formatting numbers {0:c} currency (edit fields)

    • grid view and detail view together

      • configure gridview first then details view (SqlDataSource1)

      • enable selection in  grid view

        • remove CustomerID/CreditLimit columns (edit columns)

        • no paging

      • write code for grid view control's "SelectedIndexChange" event (access through bolt prop)

      • DetailsView1.PageIndex=GridView1.SelectedIndex


3
The Concept of Data Binding Part 3 ... Using an Access DB

In this Lecture we will

  • Look at a simple application of databinding related to a music band site in which the data is stored in an Microsoft Access Database (DataDrivenBandBioPage)

    • add BandDataBase.mdb to AppData folder

    • Connect to an Access DB using Gridview

      • add Gridview onto page

      • choose data source (new data source)... SQL database

      • choose BandDataBase.mdb in Data Connection screen dropdown menu

      • configure Select statement ... choose the artist table

        • Select * From [Artists] Where 

      • Remove "PictureName" field after Gridview appears

    • Editing Gridview properties

      • HeaderStyle ... BackColor, BorderColor, BorderStyle, BorderWith

  • Give you a chance to experiment with the Access Database by creating a GridView control of the Tours table.

    • ... Then make it look nicer... here's a couple of ideas

      • enable paging

      • set the PageStyle font size to medium to make the numbers easier to read

      • for columns choose only ShowDate, City, State, ZipCode and Tournumber

      • Format the date as {0:MM/dd/yy}

      • a white border of two pixels would look nice

      • use Autoformat to change the appearance of the table



4
Filtering Data ... Using The WHERE and ORDER BY Options

In this Lecture we will

  • Learn how to filter data from the database by creating a Select query (FilteringData)

    • Using the WHERE and ORDER BY clause options where the source is a control like a RadioList or DropDownList

    • First create the RadioList before adding a GridView (eg. Daniel value 1/Davis 2/Kevin 3/Reginald 4/Thaddeus 5

      • don't forget to set autopostback to true

      • What we eventually what is an application where a user selects a radiobutton and the records for the selected band member (1,2,3 ) is displayed in gridview

    • Next add a GridView to the page

      • create a new datasource and make a connection to the BandDatabase

      • select the ArtistJournal table and choose the IDNumber , JournalDate and Remarks fields ... notice how the wizard automatically creates the SQL statement

      • Next click on the WHERE button to construct the WHERE clause.

        • Choose the IDNumber in the Column field. For the Operator, choose =. For the Source, select Control. Select RadioButtonList1 from the ControlID list in the Parameter properties section. When we call the query method, we can pass in a value for the IDNumber (2 for example).

        • Test the query

    • Test out the page by clicking on the RadioButtonList and choosing an artist to display.

    • Next let's re-configure our WHERE clause to include AND condition

      • first add a text box to the form to hold a date

      • next click on SqlDataSource control and click on Configure Data Source

      • click on the WHERE button to add a second condition

        • choose JournalDate, operator >= with control id TxtDate

        • Click Test Query. The Parameter Values Editor opens and

          you are prompted to enter an IDNumber (enter 2) and a Date (enter 1/1/2003).

    • Lastly we add an ORDER BY clause

      • first configure data source again

      • this time click on the ORDER BY button

      • Select Remarks for the Sort by and choose descending. Notice the changes that occur to the SELECT statement. Click OK.

    • Code Tweaking

      • Modifying the SQL statement by using the Query Builder (demo only)

        • click on the SqlDataSource

        • select the ellipsis on the SelectQuery property (property window on right side of Visual Studio screen)

5
Filter Data Quiz

Filter Data Quiz ... Select Queries

6
Implementing CRUD in FormView

In this Lecture we will

  • Learn how to implement a FormView control which allows us to access CRUD (create,read , update,delete)

    • GridView displays multiple records in a database in a grid style. We are able to delete, edit and select, but we

      are not able to insert. The FormView on the other hand allows for creation of data (new)

    • We used the DetailsView control to display one record at a time. The FormsView control displays one record at a time as well. So, what is the difference? The basic difference is that the FormsView control allows you to edit more features of the templates

      whereas the DetailsView provides a standard block style with limited template editing.

  • Use an SQL data source (customer.mdf)

    • need to make proper connection string (add data source to web form first ... SqlDataSource)

    • configure data source

    • choose *

    • then go into advanced when databinding

      • generate insert/update/delete statements

      • use optimistic concurrency

      • database must use key fields if you want to be able to edit the table through web page

    • turn on paging in FormView control

  • Experiment with Web App

    • adding new records (Create)

    • editing records (Update)

    • deleting records (Delete)

    • viewing the updated table (Read)

    • ... go into DB Explorer and view actual raw table data to observe changes


7
DataBinding Challenge

In this Lecture we will

  • Challenge you to  create a new database with SQL Server Express. 

  • This database will store historical weather data, so you will create a table to keep track of weather details like temperature, rainfall, and so on.

  •  Later you will build an interface to add weather data for all clients, so you will also store the location in this database.

8
DataBinding Recap and Extension Part 1 ... Using a DropDown List To Filter Data

In this Lecture we will

  • Create an ASP.NET Web Application that implements a DropDown List that is data bound and filters records into a GridView (BandTour)


    • Tour number is in dropdown list  (enable PostBack)

      • Tour Table from BandDatabase is chosen

      • This data source only contains the field Tour Numbers ... with Return only unique rows specified

    • Records filtered into GridView

      • add GridView choosing new datasource (don't use SqlDatasource1)

        • choose same connection string (ConnectionString BandTour)

        • when you choose the connection string you want to reuse the same connection string . That's because the connection string only tells the control where the database is located, it doesn't specify any tables or views within the database.

      • this data source contains all the fields + WHERE clause + ORDER BY

        • set WHERE clause for TourNumber = DropDownList1

        • ORDER BY TourNumber and ShowDate

        • Select Advanced and check the Generate INSERT, UPDATE and DELETE statements as well as the Use optimistic concurrency boxes. Recall that optimistic concurrency will detect whether someone else has modified the record during the time that you pulled it up on your screen and not perform the update.

      • In the GridView control select Edit Columns. Edit the Selected fields to include TourNumber, ShowDate and City. For the ShowDate column, change the DataFormat property to {0:d}

        • enable Paging, Deleting and Selection

        • Set Paging Properties.... Set PageSize to 5

        • Choose Auto Format and pick a style


9
DataBinding Recap and Extension Part 2 ... Using a Calendar To Filter Data

In this Lecture we will

  • Create an ASP.NET Web Application that implements a Calendar control that is used to filter dates for records that are fed in a GridView for display.... A Band Journal Search Page (ArtistJournal)

    • We add a calendar control to the Web Form which will be used to select  dates which will be placed into textboxes

      • Use a single calendar control for the Start Date and the End Date...C# code checks for textbox contents and places the chosen date in the appropriate Start or End date textbox

    • The textbox entries are then used to filter records into a GridView

      • note the use of two WHERE clauses

      • JournalDate >= TxtStart and JournalDate <=TxtEnd

10
Working with a Relational Database

In this Lecture we will

  • Learn to create a Relational Database and connect it to a ASP.NET Web Form (ASPandRelationalDB)

  • Look at this Scenario

    • The "band" wants us to add a Favorite Songs page to the web site. They want it to show a fan’s name, their favorite songs, a comment and if they are a member of the StreetTeam – the group of active fans that help promote the band. Easy enough since this information is all in the Fans table. Here's the hard part ⎯ they also want the Favorite Songs page to show the Album Name, Album Number and Track Number. But that information is in a different table; it's in the AlbumTracks table. So we have some work to do there..... That's where the concept of Relational Databases will come into play

    • Fields in Fans Table

      ID
      Password
      Name
      BirthDate
      Gender
      City
      State
      Email
      FavoriteSong***
      StreetTeam
      Comment


      Fields in AlbumTracks Table

      AlbumNumber
      AlbumName
      TrackNumber
      TrackName ***

    • If you look carefully at the data in these tables, you see that the information in the FavoriteSong field of the Fans table is the same as the information in the TrackName field of the AlbumTracks table. That is, both of these fields contain song titles. In other words, the data in the Fans table is connected to or "related" to the data in the AlbumTracks table through the fields FavoriteSong and TrackName. This is the essential element of a "relational database" ⎯ information in one table can be related to information in another table through fields that hold common information (in this case song titles). Let's say we wanted the name of the album (AlbumName) that contains a fan's favorite song. We would look for the name of the favorite song in the FavoriteSong field of the Fans table. Then we search for the same song in the TrackName field of the AlbumTracks table. Once we find the matching favorite song in the AlbumTracks table, we get the AlbumName for that particular record.

    • Here's another example. The Albums table contains a field called AlbumNumber. The AlbumTracks table also contains a field called AlbumNumber. Both fields contain an integer: 1 denoting the first album and 2 denoting the second album (and we hope there will be many more in the future). The information in both tables is related through their AlbumNumber fields. Using the AlbumNumber field in the AlbumTracks table, we can find the same AlbumNumber in the Albums table. Once we know which record has the same AlbumNumber, we can get other information from the Albums table such as Release Year and Label.

  • First add a GridView and connect it to the BandDatabase

  • When we configure the Select statement we need to select fields from the Fans and Album Tracks tables

    • Configure Select using custom SQL (Multi-Table Query-Query Builder) ... selecting fields from two tables

      • Add the Fans and AlbumTracks Tables to the Query Builder

      • Check the boxes next to the column names we want to display:

        Fans: Name, Favorite Song, Street Team, Comments

        Album Tracks: Album Number, Album Name, Track Number, TrackName

      • FavoriteSong field and TrackName are connecting fields

      • then click on FavoriteSong and drag toward TrackName (this creates relationship).This will match (or join) the two tables on those column names when their values are equal.

      • press the "Execute Query Button" ... and then "Test Query"

  • Start your application. The grid is populated with data from the Fans table and the AlbumTracks table. Note that the same song is listed in the FavoriteSong field and the TrackName field.

    • clean up the grid ... eliminate redundant information (make TrackName invisible) and move AlbumNumber down once so that it is just before TrackNumber

    • Sort the records by AlbumNumber then by TrackNumber (need to get back into QueryBuilder)

      • Click SqlDataSource ... then go over to properties and choose SelectQuery

      • Click in the Sort Type cell in the AlbumNumber row and select Ascending. The Sort Order will be 1. Click in the Sort Type cell

        for the TrackNumber row and select Ascending. The Sort Order will be 2.

11
Final Exam
You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!
4.6
4.6 out of 5
97 Ratings

Detailed Rating

Stars 5
61
Stars 4
30
Stars 3
6
Stars 2
0
Stars 1
1
002e2c6c7b7ab5418ab5bbc3cfa4830f
30-Day Money-Back Guarantee

Includes

7 hours on-demand video
Full lifetime access
Access on mobile and TV
Certificate of Completion