LAB MANUAL - Lecture Notes

Transcription

LAB MANUAL.NET TECHNOLOGIES LABBCA-303School of Computing Science & EngineeringVersion : 1Date: 14/10/2013Drafted by : Gurpreet Singh1

Table of ContentsPage no.1. Course details1.1. Course objective (s)031.2. Pre-requisites031.3. Learning Outcomes031.4. Syllabus & References042. List of Experiments063. Experimental Setup details for the course.4. Experiment details085. Guidelines for continuous assessment355.1. Format for continuous assessment5.2. Format for internal end semester assessment2

COURSE DETAILSCourse Objective(s)Students will gain the ability to implement the algorithms in C#.net, VB.net and ASP.net.Pre-requisite1. Programming experience of ‘.NET Technologies’ (BCA-303)Learning Out comeAt the end of the course student will be able to:1. Create Simple application using web controls2. Work with States of ASP.NET Pages & Adrotator Control3. Use of calendar control, Treeview control & Validation controls4. Query textbox and Displaying records & Display records by using database5. Datalist link control & Databinding using dropdownlist control6. Inserting record into a database & Deleting record into a database7. Databinding using datalist control & Datalist control templates8. Databinding using datagrid & Datagrid control template9. Datagrid hyperlink & Datagrid button column10. Datalist event & Datagrid paging11. Creating own table format using datagridSyllabus & ReferencesUnit I: Introduction9 lecture hoursIntroducing C#, Understanding .NET, Overview of C#, Literals, Variables, Data Types, Operators,Expressions, Branching, Looping, Methods, Arrays, Strings, Structures, Enumerations, Classes,Objects, Inheritance, Polymorphism, Interfaces, Operator Overloading, Delegates, Events, Errors3

and Exceptions, Defining classes and class members. Assembly, Components of Assembly, Privateand Shared Assembly, Garbage Collector, JIT compiler. Namespaces Collections, Comparisonsand Conversions, Delegates and Events.Unit II:C#7 lecture hoursGetting Started with .Net Framework, Exploring Visual Studio .NET, Inside a C# Program, DataTypes, Statements, Arrays, Using Strings, Objects, Classes and Structs, Properties, Inheritance,Indexers, Delegates, Events, Namespaces, Generics, Collections and Data Structures, ExceptionHandling, Threading, Using Streams and Files, Reflection, Assemblies, versioning, WindowsForms, Controls, Data binding to Conrols, Advanced Database Programming using ADO.net,Using GDI ,Networking,.net Remoting, Manipulating XML.Unit III: VB.Net8 lecture hoursCreating Applications with Visual Basic.NET, Variables, Constants, and Calculations, MakingDecisions and Working with Strings, Lists, Loops, Validation, Sub Procedures and Functions,Multiple Forms, Standard Modules, and Menus, Arrays, Timers, Form Controls, File Handling,Exception Handling, Working with Databases, Advanced Database Programming using ADO.net,Classes, Generics, Collections, Inheritance, Custom Controls, Packaging & deployment, UsingCrystal Reports.Unit IV: ASP.NET9 lecture hoursBuilding a Web Application, Examples Using Standard Controls, Using HTML Controls,Validating Form Input Controls using Validation Controls, Understanding Applications and State,Applying Styles, Themes, and Skins, Creating a Layout Using Master Pages, Binding to Databasesusing Controls, Data Management with ADO.net, Creating a Site Navigation Hierarchy,Navigation Controls , Membership and Role Management, Login Controls, Securing Applications,Caching For Performance, Working with XML, Using Crystal Reports in Web Forms.Unit V: DBMS8 lecture hoursDatabases: Introduction, Using SQL to work with database, retrieving and manipulating data withSQL, working with ADO.NET, ADO.NET architecture, ASP.NET data control, data sourcecontrol, deploying the web site. Crystal reports. LINQ: Operators, implementations, LINQ toobjects, XML, ADO.NET, Query Syntax.Reference Books1. Visual studio 2010 - A beginners guide - Joseph Mayo3. Jeffrey R. Shapiro “The Complete Reference Visual Basic .NET” Tata Mcgraw Hill (2002Edition).4. Pro ASP.NET 4 in C# 2010, MacDonald and Freeman5. Visual Studio 2010 and .NET 4 Six-in-One (Wrox Programmer to Programmer)4

Mode of Evaluation: Quiz/Assignment/ Seminar/Written ExaminationTheoryComponentsMarksTotal MarksScaled MarksInternal50LaboratorySEE50100Theory andlaboratorySEE50100100Internal507525Relationship between the Course Outcomes (COs) and Program Outcomes (POs)Mapping between Cos and PosCourse Outcomes (COs)Sl. s245Life-long Learning2Project managementand finance1CommunicationDesign/developmentof solutionsCourse NameIndividual or teamworkProblem analysisCourseCodeProgramOutcome t andsustainabilityQuery textbox and Displaying records & Display records by using databaseDatalist link control & Databinding using dropdownlist controlInserting record into a database & Deleting record into a databaseDatabinding using datalist control & Datalist control templatesDatabinding using datagrid & Datagrid control templateDatagrid hyperlink & Datagrid button columnDatalist event & Datagrid pagingCreating own table format using datagridThe engineer andsociety3Modern tool usageCreate Simple application using web controlsWork with States of ASP.NET Pages & Adrotator ControlUse of calendar control, Treeview control & Validation controlsConductinvestigations ofcomplex problems126789101112322131 addressed to small extent2 addressed significantly3 major part of course5

Course Lab Outcomes AssessmentThe laboratory component strongly contributes towards the program outcomeDesign/development of solutions-PO(3). This evaluation method will be used for the evaluationof lab and program outcomes of this course.Direct Measurement ReportCSE311P Outcome (3) Report FormMeasure– percent of students scoring at least 70% marks in lab.Target – 70% of studentsLIST OF EXPERIMENTSTopicSr No.12345678Simple application using web controlsa) Finding factorial Valueb) Money Conversionc) Quadratic Equationd) Temperature Conversione) Login controlStates of ASP.NET PagesAdrotator ControlCalendar controla) Display messages in a calendar controlb) Display vacation in a calendar controlc) Selected day in a calendar control using styled) Difference between two calendar datesTreeview controla) Treeview control and datalistb) Treeview operationsValidation controlsQuery textbox and Displaying recordsDisplay records by using database6

9101112131415161718192021Datalist link controlDatabinding using dropdownlist controlInserting record into a databaseDeleting record into a databaseDatabinding using datalist controlDatalist control templatesDatabinding using datagridDatagrid control templateDatagrid hyperlinkDatagrid button columnDatalist eventDatagrid pagingCreating own table format using datagridEXPERIMENTAL SETUP DETAILS FOR THE COURSESoftware RequirementsMicrosoft Visual Studio 2010, Asp .net Framework 2.0/ 3.0/3.5/4.0Microsoft SQL Express 2005 database engine.Hardware RequirementsNo specific requirements. Any computer Hardware capable of running DOS can beused for this course.7

EXPERIMENT DETAILSExperiment No:1(a)TitleObjectiveAlgorithmWrite a Program to generate the factorial operation.To calculate factorial of numberPartial Class DefaultInherits System.Web.UI.PageProtected Sub Button1 Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.ClickDim i As IntegerDim a As DoubleDim f As Double f 1i 1a TextBox1.TextWhile i af f*ii i 1End WhileLabel3.Text f & "unit"End SubEnd ClassSample output8

Experiment No:1(b)TitleWrite a Program to perform Money Conversion.ObjectiveTo convert money from one currency to another.AlgorithmPartial Class DefaultInherits System.Web.UI.PageProtected Sub Button1 Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.ClickDim a As Doublea TextBox1.TextIf DropDownList1.SelectedItem.Value "Rupees" AndDropDownList2.SelectedItem.Value "Doller" ThenLabel5.Text a * 45 & " "ElseIf DropDownList1.SelectedItem.Value "Rupees" AndDropDownList2.SelectedItem.Value "Zen" ThenLabel5.Text a * 43 & "Z"ElseIf DropDownList1.SelectedItem.Value "Rupees" AndDropDownList2.SelectedItem.Value "Yen" ThenLabel5.Text a * 42 & "Y"ElseIf DropDownList1.SelectedItem.Value "Doller" AndDropDownList2.SelectedItem.Value "Rupees" ThenLabel5.Text a * 33 & "R"ElseIf DropDownList1.SelectedItem.Value "Doller" AndDropDownList2.SelectedItem.Value "Zen" ThenLabel5.Text a * 32 & "Z"ElseIf DropDownList1.SelectedItem.Value "Doller" AndDropDownList2.SelectedItem.Value "Yen" ThenLabel5.Text a / 31 & "y"ElseIf DropDownList1.SelectedItem.Value "Zen" AndDropDownList2.SelectedItem.Value "Rupees" ThenLabel5.Text a * 45 & "R"ElseIf DropDownList1.SelectedItem.Value "Zen" AndDropDownList2.SelectedItem.Value "Doller" ThenLabel5.Text a * 46 & " "ElseIf DropDownList1.SelectedItem.Value "Zen" AndDropDownList2.SelectedItem.Value "Yen" ThenLabel5.Text a * 47 & "Y"ElseIf DropDownList1.SelectedItem.Value "Yen" AndDropDownList2.SelectedItem.Value "Rupees" ThenLabel5.Text a / 34 & "R"ElseIf DropDownList1.SelectedItem.Value "Yen" AndDropDownList2.SelectedItem.Value "Doller" ThenLabel5.Text a / 35 & " "ElseIf DropDownList1.SelectedItem.Value "Yen" AndDropDownList2.SelectedItem.Value "Zen" ThenLabel5.Text a / 36 & "Z"Else : DropDownList1.SelectedItem.Value DropDownList2.SelectedItem.Value "Zen"MsgBox("You Select Same Currency")End IfEnd SubEnd Class9

Sample outputExperiment No:1(c)TitleWrite a Program to generate the Quadratic Equation.ObjectiveTo find out roots of a quadric equation.AlgorithmPartialClass DefaultInherits System.Web.UI.PageProtected Sub Button1 Click(ByVal sender As Object, ByVal eAsSystem.EventArgs) Handles Button1.ClickDim a As DoubleDim b As DoubleDim c As DoubleDim s As DoubleDim x1 As DoubleDim x2 As Doublea TextBox1.Textb TextBox2.Textc TextBox3.Texts Math.Sqrt(b *b - 4 * a * c)If (b * b - 4 * a * c) 0 ThenLabel5.Text "Roots are Equal"x1 (-b s) / 2 * ax2 (-b - s) / 2 * aLabel6.Text "The Roots : " & x1ElseIf (b * b - 4* a * c) 0 ThenLabel5.Text "The Roots are Imaginary"Else Label5.Text "The Roots are Not Equal"x1 (-b s) / 2 * ax2 (-b - s) / 2 * a10

Label6.Text "The Roots " & x1 & "or" & x2EndIfEndSubSample outputExperiment No:1(d)TitleWrite a Program to generate the Temperature Conversion.ObjectiveTo convert temperature from Fahrenheit to Celsius or vice versaAlgorithmPartial Class DefaultInherits System.Web.UI.PageProtected Sub Button1 Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.ClickDim a As DoubleDim f As DoubleDim c As Doublea TextBox1.TextIf RadioButton1.Checked Then c (a - 32) * 5 / 9 Label4.Text c & "f"ElseIf RadioButton2.Checked Then f (a * 9 / 5) 32 Label4.Text f & "c"ElseMsgBox("Select one Option") End IfEnd Sub End class11

Sample outputExperiment No:1(e)TitleWrite a Program to generate the Login control.ObjectiveTo develop our own login controlAlgorithmPartial Class DefaultInherits System.Web.UI.PageProtected Sub Login1 Authenticate(ByVal sender As Object, ByVal e AsSystem.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.AuthenticateIf Login1.UserName "Database" And Login1.Password "Jaiswal" Then MsgBox("You aresuccessfully Logged in")ElseMsgBox("Error:Loggedin")End IfIf Application("i") 3 ThenMsgBox("You are Blocked")Login1.Enabled FalseEnd IfEnd SubProtected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadApplication("i") Int(Application("i") 1)If Application("i") 3 ThenApplication("i") 0End IfEnd SubEnd ClassGlobal Application: %@ Application Language "VB" % script runat "server" Sub Application Start(ByVal sender As Object, ByVal e As EventArgs)Application("i") 0End Sub12

SubApplication End(ByVal sender As Object, ByVal e As EventArgs)End SubSubApplication Error(ByVal sender As Object, ByVal e As EventArgs)End SubSubSession Start(ByVal sender As Object, ByVal e As EventArgs)End SubSub Session End(ByVal sender As Object, ByVal e As EventArgs)End Sub /script Sample outputAfter enter the wrong passwordAfter log in three times the login will be blockedExperiment No:2TitleObjectiveWrite a Program to perform Asp.Net state.To convert temperature from Fahrenheit to Celsius or vice versaAlgortihmPartial Class DefaultInherits System.Web.UI.PageProtected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadApplication("visits") Int(Application("visits") 1)Label6.Text Application("visits")Label8.Text Session("My text").ToStringEnd Sub13

Protected Sub Button1 Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.ClickDim txt As String TextBox1.TextViewState.Add("Item", txt)Dim Item As String ViewState("Item").ToStringLabel3.Text ItemEnd SubEnd ClassGlobal Application: %@ Application Language "VB" % script runat "server" SubApplication Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runson application startupApplication("visits") 0End SubSubApplication End(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs onapplication shutdownEnd SubSub Application Error(ByVal sender As Object, ByVal e As EventArgs)Sub Session Start(ByVal sender As Object, ByVal e As EventArgs)Session("My text") "I am the user"End SubSubSession End(ByVal sender As Object, ByVal e As EventArgs)modeEnd Sub /script Sampleoutput14

Experiment No:3TitleObjectiveWrite a Program to create an Advertisement using Ad rotator.To create an ad rotatorAlgortihm ?xml version "1.0" encoding "utf-8" ? Advertisements Ad ImageUrl .\image\p1.jpg /ImageUrl NavigateUrl www.pepsi.com /NavigateUrl AlternativeText Pepsi /AlternativeText Keyword softdrink /Keyword Impression 2 /Impression /Ad Ad ImageUrl .\image\p2.jpg /ImageUrl NavigateUrl www.Excel.com /NavigateUrl AlternativeText Excel /AlternativeText Keyword softdrink /Keyword Impression 2 /Impression /Ad Ad ImageUrl .\image\p3.jpg /ImageUrl NavigateUrl www.7up.com /NavigateUrl AlternativeText 7up /AlternativeText Keyword softdrink /Keyword Impression 2 /Impression /Ad Ad ImageUrl .\image\p4.jpg /ImageUrl NavigateUrl www.Mirinda.com /NavigateUrl AlternativeText Mirinda /AlternativeText Keyword softdrink /Keyword Impression 2 /Impression /Ad /Advertisements SampleoutputVIEW 1VIEW 215

Experiment No:4(a)TitleWrite a Program to display the Holiday in calendar.ObjectiveTo display holiday in calenderAlgortihmPartial Class DefaultInherits System.Web.UI.PageDim Holidays(13, 32)Protected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadHolidays(10, 12) "Birthdays"Holidays(10, 15) "Aniversary"End SubProtected Sub Calendar1 DayRender(ByVal sender As Object, ByVal e AsSystem.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRenderIf e.Day.IsOtherMonth Then e.Cell.Controls.Clear()ElseDim adate As Date e.Day.DateDim aHolidays As String Holidays(adate.Month, adate.Day) If (Not aHolidays Is Nothing)ThenDim alabel As New Label() alabel.Text " br " & aHolidays e.Cell.Controls.Add(alabel)End IfEnd IfEnd SubEnd ClassSampleoutput16

Experiment No:4(b)TitleWrite a Program to display the vacation in calendar.ObjectiveTo display the vacation in calendarAlgortihmPartial Class DefaultInherits System.Web.UI.PageProtected Sub Calendar1 DayRender(ByVal sender As Object, ByVal e AsSystem.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRenderDim vocationstyle As New Style()With vocationstyle.BackColor System.Drawing.Color.Yellow.BorderColor System.Drawing.Color.Black.BorderWidth New Unit(3)End WithDim weekendstyle As New Style()weekendstyle.BackColor System.Drawing.Color.SpringGreenIf ((e.Day.Date New Date(2009, 11, 23)) And (e.Day.Date New Date(2009, 11, 30)))Thene.Cell.ApplyStyle(vocationstyle) ElseIf (e.Day.IsWeekend) Thene.Cell.ApplyStyle(weekendstyle) End IfEnd SubSampleoutput17

Experiment No:4(c)TitleWrite a Program to display the selected date in the calendar.ObjectiveTo display the selected date in the calendar.AlgortihmPartial Class DefaultInherits System.Web.UI.PageDim Holidays(13, 32)Protected Sub Calendar3 DayRender(ByVal sender As Object, ByVal e AsSystem.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar3.DayRenderDim vacationstyle As New Style()With vacationstyle.BackColor System.Drawing.Color.Yellow.BorderColor System.Drawing.Color.Purple.BorderWidth New Unit(3)End WithDim weekendstyle As New Style()weekendstyle.BackColor System.Drawing.Color.GreenIf ((e.Day.Date Calendar1.SelectedDate) And (e.Day.Date tionstyle) ElseIf (e.Day.IsWeekend) Thene.Cell.ApplyStyle(weekendstyle) End IfIf e.Day.IsOtherMonth Then e.Cell.Controls.Clear()ElseDim aDate As Date e.Day.DateDim aHolidays As String Holidays(aDate.Month, aDate.Day) If (Not aHolidays Is Nothing)ThenDim alabel As Label New Label() alabel.Text " br " & aHolidayse.Cell.Controls.Add(alabel)End IfEnd IfEnd SubProtected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadHolidays(8, 15) "IndependenceDay"Holidays(1, 26) "RepublicDay"Holidays(10, 12) "Birthday"End SubProtected Sub Calendar1 SelectionChanged(ByVal sender As Object, ByVal e AsSystem.EventArgs) Handles Calendar1.SelectionChangedLabel1.Text Calendar1.SelectedDateEnd SubProtected Sub Calendar2 SelectionChanged(ByVal sender As Object, ByVal e AsSystem.EventArgs) Handles Calendar2.SelectionChangedLabel2.Text Calendar2.SelectedDateEnd SubEnd Class18

SampleoutputExperiment No:4(d)TitleWrite a Program to display the Difference between the two dates in thecalendar.ObjectiveTo display the Difference between the two dates in the calendar.AlgortihmImports system.data.sqlclientPartial Class DefaultInherits System.Web.UI.PageProtected Sub Button1 Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.ClickIf floor(Calendar2.SelectedDate Calendar1.SelectedDate)ThenDim a As double Math.abs(Calendar2.SelectedDate - Calendar1.SelectedDate).TotalDaysDim y As Double a / 365 Label1.Text floor(y) & "YEARS" Dim x As Double a mode 365Dim m As Integer x / 31 Label2.Text floor(m) & "MONTHS"Dim d As Integer x mode 31Label3.Text floor(d) & "DAYS"ElseMsgBox("Invalid date")End IfEnd SubEnd Class19

SampleoutputExperiment No:5(a)TitleWrite a Program to perform Tree view operation using data list.ObjectiveTo perform Tree view operation using data list.AlgortihmPartial Class DefaultInherits System.Web.UI.PageProtected Sub Button1 Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.ClickDim checkednodes As TreeNodeCollection TreeView1.CheckedNodesDataList1.DataSource checkednodesDataList1.DataBind()End SubSampleoutput20

Experiment No:5(b)TitleWrite a Program to perform Tree view operation.ObjectiveTo perform Tree view operation.AlgortihmPartial Class DefaultInherits System.Web.UI.PageProtected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadEnd SubProtected Sub TreeView1 SelectedNodeChanged(ByVal sender As Object, ByVal e AsSystem.EventArgs) Handles TreeView1.SelectedNodeChangedDim value As String TreeView1.SelectedNode.ValueDim path As String e value select was" & value & " br ")Response.Write("The value path is " & value & " br ")End SubProtected Sub TreeView1 TreeNodeCheckChanged(ByVal sender As Object, ByVal e AsSystem.Web.UI.WebControls.TreeNodeEventArgs) HandlesTreeView1.TreeNodeCheckChangedDim value As String e.Node.ValueResponse.Write("The value collapsed was" & value & " br ")End SubProtected Sub TreeView1 TreeNodeExpanded(ByVal sender As Object, ByVal e AsSystem.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodeExpandedDim value As String e.Node.ValueResponse.Write("The value collapsed was" & value & " br ")End SubEnd ClassSampleoutputExperiment No:6TitleWrite a Program to perform validation operation.ObjectiveTo perform validation operation.AlgortihmProtected Sub Button1 Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.ClickIf IsValid ThenLabel9.Enabled FalseTextBox7.Enabled FalseEnd If21

SampleoutputExperiment No:7TitleObjectiveAlgortihmWrite a Program to bind data in a multiline textbox by querying inanother textbox.To bind data in a multiline textbox by querying in another textbox.Imports System.DataImports System.Data.SqlClientPartial Class DefaultInherits System.Web.UI.PageDim constr As String nnectionString1").Connection StringProtected Sub Button Click(ByVal sender As Object, ByVal e As System.EventArgs) HandlesButton1.ClickDim conPubs As SqlConnection Dim cmdSelect As SqlCommandDim dtrResults As SqlDataReader Dim intField As Integerconpubs New SqlConnection(constr)conPubs.Open()cmdSelect New SqlCommand(txtQuery.Text, conPubs) dtrResults cmdSelect.ExecuteReader() txtResults.Text ""22

While dtrResults.Read() txtResults.Text & vbNewLineFor intField 0 To dtrResults.FieldCount - 1txtResults.Text & d WhiledtrResults.Close()conPubs.Close()End SubEnd ClassSampleoutputExperiment No:8TitleObjectiveWrite a Program to display the phone no of an author using database.To display the phone no of an author using database.AlgortihmImports System.Data.SqlClientPartial Class DefaultInherits System.Web.UI.PageDim constr As String nnectionString1").Connection StringProtected Sub Button1 Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.ClickDim conpubs As SqlConnectionDim strselect As StringDim cmdselect As SqlCommandconpubs New SqlConnection(constr)23

strselect "select phone from Authorwhere Au fname @Au fname AndAu lname @Au lname"cmdselect New Add("@Au fname",Au fname.Text)cmdselect.Parameters.Add("@Au lname",Au lname.Text)conpubs.Open()label5.Text cmdselect.ExecuteScalar() conpubs.Close()End SubEnd ClassSampleoutputExperiment No:9TitleWrite a Program to create link in data list.ObjectiveTo create link in data list.AlgortihmImports System.Data.SqlClientPartial Class DefaultInherits System.Web.UI.PageDim constr As String nnectionString1").Connection StringProtected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadIf Not IsPostBack ThenBindDataList()End IfEnd Sub24

Sub BindDatalist()Dim conpubs As SqlConnection Dim cmdselect As SqlCommand Dim dtrAuthor AsSqlDataReaderconpubs New SqlConnection(constr) conpubs.Open()cmdselect New SqlCommand("Select * from Author", conpubs) dtrAuthor cmdselect.ExecuteReader() dtrlstAuthor.DataSource onpubs.Close()End SubProtected Sub dtrlstAuthor ItemCommand(ByVal source As Object, ByVal e gs) edIndex e.Item.ItemIndexBindDatalist()End SubEnd ClassSampleoutputExperiment No:10TitleWrite a Program to display how data bind using dropdown list.ObjectiveTo display how data bind using dropdown list.AlgortihmImports System.Data.SqlClientPartial Class DefaultInherits System.Web.UI.PageDim constr As String nnectionString1").Connection StringProtected Sub Button1 Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.ClickLabel1.Text "you pick" & DropDownList1.SelectedValueEnd SubProtected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadIf Not IsPostBack ThenDim conpubs As SqlConnectionDim cmdselect As SqlCommandDim dtrAuthor As SqlDataReaderconpubs New SqlConnection(constr)cmdselect New SqlCommand("select Au fname from Author", conpubs)conpubs.Open()dtrAuthor cmdselect.ExecuteReader()DropDownList1.DataSource dtrAuthorDropDownList1.DataTextField "Au fname"25

lose()End IfEnd SubEnd ClassSampleoutputExperiment No:11TitleWrite a Program to insert the data in to database using Execute-NonQuery.ObjectiveTo insert the data in to database using Execute-Non Query.AlgortihmImports System.Data.SqlClientPartial Class DefaultInherits System.Web.UI.PageDim constr As String nnectionString1").Connection StringProtected Sub Button1 Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.ClickDim conpubs As SqlConnection Dim strInsert As StringDim cmdInsert As SqlCommandconpubs New SqlConnection(constr)strInsert "Insert Author(Au fname,Au lname)values(@Au fname,@Au lname)"cmdInsert New SqlCommand(strInsert, conpubs) cmdInsert.Parameters.Add("@Au fname",txtfname.Text) cmdInsert.Parameters.Add("@Au lname", txtlname.Text) lose()Response.Write(”New Rowinserted”) End SubEnd ClassSampleoutput26

Experiment No:12TitleWrite a Program to delete the data in to database using Execute nonquery.ObjectiveTo delete the data in to database using Execute non-query.AlgortihmImports System.Data.SqlClientPartial Class DefaultInherits System.Web.UI.PageDim constr As String ectionString1").ConnectionSt ringProtected Sub Button1 Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.ClickDim conpubs As SqlConnection Dim strdelete As StringDim cmddelete As SqlCommandconpubs New SqlConnection(constr)strdelete "delete from Author where Au fname @Au fname" cmddelete NewSqlCommand(strdelete, conpubs) cmddelete.Parameters.Add("@Au fname", ery() Response.Write("Row delete") conpubs.Close()End SubEnd ClassSampleoutputExperiment No:13TitleWrite a Program to bind data using data list.ObjectiveTo bind data using data list.AlgortihmImports System.Data.SqlClientPartial Class DefaultInherits System.Web.UI.PageDim constr As String nnectionString1").Connection StringProtected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadDim conpubs As SqlConnection Dim cmdselect As SqlCommand Dim dtrAuthor As27

SqlDataReaderconpubs New SqlConnection(constr)cmdselect New SqlCommand("Select Au fname from Author", conpubs) conpubs.Open()dtrAuthor cmdselect.ExecuteReader() dlstAuthor.DataSource dtrAuthordlstAuthor.DataBind() dtrAuthor.Close()conpubs.Close() End SubEnd ClassSampleoutputExperiment No:14TitleWrite a Program to bind data using template in data list.ObjectiveTo bind data using template in data list.AlgortihmImports System.Data.SqlClientPartial Class DefaultInherits System.Web.UI.PageDim constr As String nnectionString1").Connection StringProtected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadDim conpubs As SqlConnection Dim cmdselect As SqlCommand Dim dtrAuthor AsSqlDataReaderconpubs New SqlConnection(constr)cmdselect New SqlCommand("Select * from Author", conpubs) conpubs.Open()dtrAuthor cmdselect.ExecuteReader() dtrlstAuthor.DataSource dtrAuthordtrlstAuthor.DataBind() dtrAuthor.Close()conpubs.Close() End SubEnd ClassSampleoutput28

Experiment No:15TitleWrite a Program to bind data using data grid.ObjectiveTo bind data using data grid.AlgortihmImports System.Data.SqlClientPartial Class DefaultInherits System.Web.UI.PageDim constr As String ectionString1").ConnectionSt ringProtected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadDim conpubs As SqlConnectionDim cmdselect As SqlCommandconpubs New SqlConnection(constr)cmdselect New SqlCommand("select * from Author", conpubs)conpubs.Open()datagrd.DataSource .Close()End SubProtected Sub datagrd SelectedIndexChanged(ByVal sender As Object, ByVal e AsSystem.EventArgs) Handles datagrd.SelectedIndexChangedEnd SubEnd ClassSampleoutputExperiment No:16TitleWrite a Program to bind data using template column in data grid.ObjectiveTo bind data using template column in data grid.AlgortihmImports System.Data.SqlClientPartial Class DefaultInherits System.Web.UI.PageDim constr As String nnectionString1").Connection StringProtected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadDim conpubs As SqlConnection Dim cmdselect As SqlCommandconpubs New SqlConnection(constr)cmdselect New SqlCommand("select * from Author", conpubs) conpubs.Open()datagrd.DataSource cmdselect.ExecuteReader() datagrd.DataBind()29

conpubs.Close()End SubEnd ClassSampleoutputExperiment No:17TitleObjectiveWrite a Program to bind data using Hyperlink column in data grid.To bind data using Hyperlink column in data grid.AlgortihmImports System.Data.SqlClientPartial Class DefaultInherits System.Web.UI.PageDim constr As String nnectionString1").Connection StringProtected Sub Page Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.LoadDim conpubs As SqlConnectionDim cmdselect As SqlCommandconpubs New SqlConnection(constr)cmdselect New SqlCommand("select * from Author", conpubs)conpubs.Open()datagrdlnk.DataSource ubs.Close()End SubEnd ClassSampleoutput30

Experiment No:18TitleWrite a Program to bind data using button column in data grid.ObjectiveTo bind data using button column

Students will gain the ability to implement the algorithms in C#.net, VB.net and ASP.net. Pre-requisite 1. Programming experience of ‘.NET Technologies’ (BCA-303) Learning Out come At the end of the course student will be able to: 1. Create Simple application using web controls 2. Wor