AWD Journal
AWD Journal
namespace Arithmetic_Operations
{
class Program {
public static void Addition() {
int a, b, sum;
Console.WriteLine("Enter two numbers for addition: ");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
sum = a + b;
Console.WriteLine("Addition of " + a + " and " + b + " is " + sum);
}
public static void Subtraction() {
int a, b,sub;
Console.WriteLine("Enter two numbers for subtraction: ");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
sub = a - b;
Console.WriteLine("Subtraction of " + a + " and " + b + " is " + sub);
}
public static void Multiplication(){
int a, b, mul;
Console.WriteLine("Enter two numbers for multiplication: ");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
mul = a * b;
Console.WriteLine("Multiplication of " + a + " and " + b + " is " + mul);
}
public static void Division() {
int a, b, div;
Console.WriteLine("Enter two numbers for division: ");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
div = a / b;
Console.WriteLine("Division of " + a + " and " + b + " is " + div);
}
static void Main(string[] args) {
Addition();
Subtraction();
Multiplication();
Division();
Console.Read();
}}}
OUTPUT:
b.) Create an application to print Floyd’s triangle till n rows in C#.
INPUT:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Floyd_Triangle{
class Program {
static void Main(string[] args) {
int i, j, k = 0;
for (i = 0; i<= 4; i++) {
for (j = 1; j <i + 1; j++){
Console.Write(k++ + " ");
}
Console.Write("\n");
}
Console.ReadKey();
}}}
OUTPUT:
c.) Create an application to demonstrate following operations -
i. Generate Fibonacci series.
ii. Test for prime numbers.
INPUT:
i. Fibonacci Series Generation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Fibonacci_Series{
class Program {
static void Main(string[] args) {
int a = 0, b = 1, series, term = 0;
while (term <= 6) {
series = a + b;
Console.WriteLine(series);
a = b;
b = series;
term++;
}
Console.ReadLine();
}}}
OUTPUT:
ii. Prime Numbers Test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Prime_Test {
class Program {
static void Main(string[] args) {
int num, n = 2, term = 0;
Console.WriteLine("Enter any number: ");
num = Convert.ToInt32(Console.ReadLine());
while (n <num) {
if (num % n == 0) {
term++;
}
n = num;
}
if (term == 0) {
Console.WriteLine(num + " is a prime number.");
}
else {
Console.WriteLine(num + " is not a prime number.");
}
Console.ReadKey();
}}}
OUTPUT:
PRACTICAL NO: 2
Aim:: Write the program for the following.
a. Create a simple application to demonstrate the concepts boxing and unboxing.
INPUT:
//boxing concept
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Boxing
{
class Program
{
static void Main(string[] args)
{
int num = 2024;
Object obj = num; //boxing
num = 100;
Console.WriteLine("Value type value of num is: "+num);
Console.WriteLine("Object type value of obj is: "+obj);
Console.ReadKey();
}
}
}
OUTPUT:
//unboxing concept
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Unboxing
{
class Program
{
static void Main(string[] args)
{
int num = 23;
Object obj = num; //boxing
int i = (int)obj; //unboxing
Console.WriteLine("Value of obj object is: "+obj);
Console.WriteLine("Value of i is: " + i);
Console.ReadKey();
}
}
}
OUTPUT:
b.) Create a simple application to perform addition and subtraction using delegate.
INPUT:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Using_Delegate
{
class Program
{
public static int Addition()
{
int a, b;
Console.WriteLine("Enter two numbers for addition: ");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
return a + b;
}
public static int Subtraction()
{
int a, b;
Console.WriteLine("Enter two numbers for subtraction: ");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
return a - b;
}
public delegate int addDelegate();
public delegate int subDelegate();
static void Main(string[] args)
{
addDelegate d = new addDelegate(Addition);
subDelegate d1 = new subDelegate(Subtraction);
int addResult = d();
Console.WriteLine("Addition of numbers is: "+addResult);
int subResult = d1();
Console.WriteLine("Subtraction of numbers is: " + subResult);
Console.ReadKey();
}
}
}
OUTPUT:
c.) Create a simple application to demonstrate use of the concepts of interfaces.
INPUT:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Implementing_Interface {
interface Square {
int sqr();
}
interface Double {
int ddouble();
}
class interfaceTest : Square, Double
{
int n;
public interfaceTest(int n) {
this.n = n;
}
public int sqr() {
return n * n;
}
public int ddouble() {
return n * 2;
}
}
class Program {
static void Main(string[] args) {
int r;
interfaceTest it=new interfaceTest(20);
Square s=(Square)it;
r=s.sqr();
Console.WriteLine("Square of 20 is: "+r);
Double d=(Double)it;
r=d.ddouble();
Console.WriteLine("Double of 20 is: "+r);
Console.ReadKey();
}
}
}
OUTPUT:
PRACTICAL NO:3
Aim:: Write the program for the following.
a.) Create a simple web page with various server controls to demonstrate setting and
use of their properties. (Example :AutoPostBack)
Design View:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Name:"></asp:Label>
<asp:TextBox ID="txtname" runat="server" AutoPostBack="True"></asp:TextBox>
</div>
<asp:Label ID="Label2" runat="server" Text="Address:"></asp:Label>
<asp:TextBox ID="txtaddress" runat="server" AutoPostBack="True"></asp:TextBox>
<p>
<asp:Label ID="Label3" runat="server" Text="Gender:"></asp:Label>
</p>
<p>
<asp:RadioButton ID="rbmale" runat="server" AutoPostBack="True" Text="Male" />
<asp:RadioButton ID="rbfemale" runat="server" AutoPostBack="True" Text="Female" />
</p>
<p>
<asp:Label ID="Label4" runat="server" Text="Subjects:"></asp:Label>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
<asp:ListItem>AI</asp:ListItem>
<asp:ListItem>IOT</asp:ListItem>
<asp:ListItem>SPD</asp:ListItem>
<asp:ListItem>JAVA</asp:ListItem>
<asp:ListItem>AWD</asp:ListItem>
</asp:RadioButtonList>
</p>
<asp:Label ID="Label5" runat="server" Text="Vehicles:"></asp:Label>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True">
<asp:ListItem>BUS</asp:ListItem>
<asp:ListItem>CAR</asp:ListItem>
<asp:ListItem>AUTO</asp:ListItem>
</asp:CheckBoxList>
<br />
<asp:Label ID="Label6" runat="server" Text="Fruits:"></asp:Label>
<br />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem>Apple</asp:ListItem>
<asp:ListItem>Mango</asp:ListItem>
<asp:ListItem>Orange</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Display" />
<br />
<br />
<asp:Label ID="lblresult" runat="server" Text="Result:"></asp:Label>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC" BorderColor="#FFCC66"
BorderWidth="1px" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
ForeColor="#663399" Height="200px" OnDayRender="Calendar1_DayRender"
OnSelectionChanged="Calendar1_SelectionChanged" ShowGridLines="True" Width="220px">
<DayHeaderStyleBackColor="#FFCC66" Font-Bold="True" Height="1px" />
<NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
<OtherMonthDayStyleForeColor="#CC9966" />
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<SelectorStyleBackColor="#FFCC66" />
<TitleStyleBackColor="#990000" Font-Bold="True" Font-Size="9pt" ForeColor="#FFFFCC" />
<TodayDayStyleBackColor="#FFCC66" ForeColor="White" />
</asp:Calendar>
<br /></div>
<asp:Calendar ID="Calendar2" runat="server" BackColor="White" BorderColor="#3366CC"
BorderWidth="1px" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-
Size="8pt" ForeColor="#003399" Height="200px" Width="220px">
<DayHeaderStyleBackColor="#99CCCC" ForeColor="#336666" Height="1px" />
<NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
<OtherMonthDayStyleForeColor="#999999" />
<SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<SelectorStyleBackColor="#99CCCC" ForeColor="#336666" />
<TitleStyleBackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" Font-Bold="True"
Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
<TodayDayStyleBackColor="#99CCCC" ForeColor="White" />
<WeekendDayStyleBackColor="#CCCCFF" />
</asp:Calendar>
<p>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Show Difference" />
</p><p>
<asp:Label ID="Label1" runat="server" Text="Difference:"></asp:Label></p>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
OUTPUT:
c. Demonstrate the use of Treeview operations on the web form.
Design View:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TreeView ID="TreeView1" runat="server" ShowLines="True">
<Nodes>
<asp:TreeNode Text="Departments" Value="Departments">
<asp:TreeNode Text="I.T." Value="I.T."></asp:TreeNode>
<asp:TreeNode Text="C.S." Value="C.S."></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="I.T. Subjects" Value="I.T. Subjects">
<asp:TreeNode Text="SPD" Value="SPD"></asp:TreeNode>
<asp:TreeNode Text="IOT" Value="IOT"></asp:TreeNode>
<asp:TreeNode Text="AWD" Value="AWD"></asp:TreeNode>
<asp:TreeNode Text="AI" Value="AI"></asp:TreeNode>
<asp:TreeNode Text="AJT" Value="AJT"></asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
</div>
</form>
</body>
</html>
Web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntimetargetFramework="4.5" />
</system.web>
</configuration>
OUTPUT:
PRACTICAL NO:4
Aim:: Write the program for the following.
a.)Create a Registration form to demonstrate use of various Validation controls.
1. RangeValidator:
Design View:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Age:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="Enter value between 20-30" ForeColor="Red" MaximumValue="30"
MinimumValue="20"></asp:RangeValidator>
</div>
<p>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Show" />
</p>
<asp:Label ID="Label2" runat="server" Text="Result:"></asp:Label>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default :System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e) {
Label2.Text = TextBox1.Text;
}
}
Web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntimetargetFramework="4.5" />
</system.web>
</configuration>
OUTPUT:
2. CompareValidator:
Design View:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
<p>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" BackColor="White"
ControlToCompare="TextBox1" ControlToValidate="TextBox2" ErrorMessage="Enter same value
as above" ForeColor="Red"></asp:CompareValidator>
</p>
<p>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Show" />
</p>
<p>
<asp:Label ID="Label1" runat="server" Text="Result:"></asp:Label>
</p>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default :System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e) {
Label1.Text += TextBox2.Text;
}}
Web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntimetargetFramework="4.5" />
</system.web>
</configuration>
OUTPUT:
3. RequiredFieldValidator:
Design View:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Name: "></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Enter
Value" ControlToValidate="TextBox1" ForeColor="Red"></asp:RequiredFieldValidator>
</div>
<p>
<asp:Label ID="Label2" runat="server" Text="Roll No: "></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Enter
value" ControlToValidate="TextBox2" ForeColor="Red"></asp:RequiredFieldValidator>
</p>
<p>
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />
</p>
<p>
<asp:Label ID="Label3" runat="server" Text="Result:"></asp:Label>
</p>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default :System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e) {
Label3.Text += "</br>Name: " + TextBox1.Text + "</br>Roll No: " + TextBox2.Text;
}}
Web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntimetargetFramework="4.5" />
</system.web>
</configuration>
OUTPUT:
4. RegularExpressionValidator:
Design View:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Mob No: "></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox1"
ErrorMessage="Enter 10 digit mobile number" ForeColor="Red"
ValidationExpression=""\d{10}""></asp:RegularExpressionValidator>
</div>
<p>
<asp:Button ID="Button1" runat="server" Text="Show" OnClick="Button1_Click" />
</p>
<p>
<asp:Label ID="Label2" runat="server" Text="Result:"></asp:Label>
</p>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void Button1_Click(object sender, EventArgs e)
{
Label2.Text = TextBox1.Text;
}
}
Web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntimetargetFramework="4.5" />
</system.web>
</configuration>
OUTPUT:
5. CustomValidator:
Design View:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Enter Number: "></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="Enter number which is divisible by 2" ForeColor="Red"
OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
</div>
<p>
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />
</p><p>
<asp:Label ID="Label2" runat="server" Text="Result:"></asp:Label>
</p>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label2.Text += TextBox1.Text;
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
int num = int.Parse(TextBox1.Text);
if (num % 2 == 0)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
}
Web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntimetargetFramework="4.5" />
</system.web>
</configuration>
OUTPUT:
b.) Create Web Form to demonstrate use of Adrotator Control.
Design View:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/XMLFile.xml"></asp:XmlDataSource>
</div>
</form>
</body>
</html>
XMLFile.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>GoogleImage.jpg</ImageUrl>
<NavigateUrl>http://www.google.com</NavigateUrl>
<AlternateText>Google Site</AlternateText>
</Ad>
<Ad>
<ImageUrl>FacebookImage.jpg</ImageUrl>
<NavigateUrl>http://www.facebook.com</NavigateUrl>
<AlternateText>Facebook Site</AlternateText>
</Ad>
</Advertisements>
OUTPUT:
c.) Create Web Form to demonstrate use User Controls.
Design View:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="This is User Control" Font-Bold="True" Font-
Size="XX-Large" Font-Underline="True"></asp:Label>
<br /><br />
<asp:Label ID="Label2" runat="server" Text="Name: "></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
<asp:Label ID="Label3" runat="server" Text="City: "></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<p>
<asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click"
/></p><p>
<asp:Label ID="Label4" runat="server" Text="Result:"></asp:Label>
</p>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default :System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e) {
Label4.Text += "</br>Your name is " + TextBox1.Text + "</br>You are from " +
TextBox2.Text;
}}
OUTPUT:
PRACTICAL NO:5
Aim:: Write the program for the following.
a.) Create Web Form to demonstrate use of Website Navigation controls.
Design View:
Home.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home"
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
<br />
</div>
<asp:Menu ID="Menu1" runat="server" BackColor="#F7F6F3"
DataSourceID="SiteMapDataSource1" DynamicHorizontalOffset="2" Font-Names="Verdana" Font-
Size="0.8em" ForeColor="#7C6F57" StaticSubMenuIndent="10px">
<DynamicHoverStyleBackColor="#7C6F57" ForeColor="White" />
<DynamicMenuItemStyleHorizontalPadding="5px" VerticalPadding="2px" />
<DynamicMenuStyleBackColor="#F7F6F3" />
<DynamicSelectedStyleBackColor="#5D7B9D" />
<StaticHoverStyleBackColor="#7C6F57" ForeColor="White" />
<StaticMenuItemStyleHorizontalPadding="5px" VerticalPadding="2px" />
<StaticSelectedStyleBackColor="#5D7B9D" />
</asp:Menu>
</form>
</body>
</html>
AboutUs.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AboutUs.aspx.cs"
Inherits="AboutUs" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div><p>
We are offering B.Sc.I.T. Course in the B.N.N. College.
</p><p>
The course duration is of 3 years.
</p>
</div>
</form>
</body>
</html>
ContactUs.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ContactUs.aspx.cs"
Inherits="Message" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div><p>
Management Contact:8976574534
</p><p>
Office Contact:9876897645
</p>
</div>
</form>
</body>
</html>
Web.sitemap:
<?xml version="1.0" encoding="utf-8" ?>
<siteMapxmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNodeurl="Home.aspx" title="Home Page" description="Home Page">
<siteMapNodeurl="AboutUs.aspx" title="AboutUs Page" description="AboutUs Page" />
<siteMapNodeurl="ContactUs.aspx" title="ContactUs Page" description="ContactUs Page" />
</siteMapNode>
</siteMap>
OUTPUT:
b.) Create a web application to demonstrate use of Master Page and content page.
Design View:
MasterPage.master:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs"
Inherits="MasterPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
<br />
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
<br />
<asp:ContentPlaceHolder ID="ContentPlaceHolder3" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Default.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Label ID="Label1" runat="server" Text="Advanced Web Development"></asp:Label>
<br />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<asp:Label ID="Label2" runat="server" Text="Advanced Java Technologies"></asp:Label>
<br />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">
<asp:Button ID="Button1" runat="server" Text="Click Here" OnClick="Button1_Click" />
</asp:Content>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default :System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Artificial Intelligence & Applications";
Label2.Text = "Software Project Development";
}
}
OUTPUT:
PRACTICAL NO:6
Aim:: Write the program for the following.
a.) Create a web application for inserting and deleting records from a database.
Design Views:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataKeyNames="Id" DataSourceID="SqlDataSource1" Height="50px" Width="125px">
<Fields>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True"
SortExpression="Id" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country"
/>
<asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
<asp:CommandField ShowDeleteButton="True" ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues" ConnectionString="<%$
ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [Student] WHERE
[Id] = @original_Id AND (([FirstName] = @original_FirstName) OR ([FirstName] IS NULL AND
@original_FirstName IS NULL)) AND (([LastName] = @original_LastName) OR ([LastName] IS
NULL AND @original_LastName IS NULL)) AND (([City] = @original_City) OR ([City] IS
NULL AND @original_City IS NULL)) AND (([Country] = @original_Country) OR ([Country] IS
NULL AND @original_Country IS NULL)) AND (([Phone] = @original_Phone) OR ([Phone] IS
NULL AND @original_Phone IS NULL))" InsertCommand="INSERT INTO [Student] ([Id],
[FirstName], [LastName], [City], [Country], [Phone]) VALUES (@Id, @FirstName, @LastName,
@City, @Country, @Phone)" OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Student]" UpdateCommand="UPDATE [Student] SET
[FirstName] = @FirstName, [LastName] = @LastName, [City] = @City, [Country] = @Country,
[Phone] = @Phone WHERE [Id] = @original_Id AND (([FirstName] = @original_FirstName) OR
([FirstName] IS NULL AND @original_FirstName IS NULL)) AND (([LastName] =
@original_LastName) OR ([LastName] IS NULL AND @original_LastName IS NULL)) AND
(([City] = @original_City) OR ([City] IS NULL AND @original_City IS NULL)) AND (([Country]
= @original_Country) OR ([Country] IS NULL AND @original_Country IS NULL)) AND
(([Phone] = @original_Phone) OR ([Phone] IS NULL AND @original_Phone IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_Country" Type="String" />
<asp:Parameter Name="original_Phone" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Id" Type="Int32" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Country" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Country" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_Country" Type="String" />
<asp:Parameter Name="original_Phone" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
OUTPUT:
Database:
b.) Create a web application to display Using Disconnected Data Access and
Databinding using GridView.
Design View:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Show
Disconnected Data" />
</div>
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Id" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True"
SortExpression="Id" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country"
/>
<asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues" ConnectionString="<%$
ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [Student] WHERE
[Id] = @original_Id AND (([FirstName] = @original_FirstName) OR ([FirstName] IS NULL AND
@original_FirstName IS NULL)) AND (([LastName] = @original_LastName) OR ([LastName] IS
NULL AND @original_LastName IS NULL)) AND (([City] = @original_City) OR ([City] IS
NULL AND @original_City IS NULL)) AND (([Country] = @original_Country) OR ([Country] IS
NULL AND @original_Country IS NULL)) AND (([Phone] = @original_Phone) OR ([Phone] IS
NULL AND @original_Phone IS NULL))" InsertCommand="INSERT INTO [Student] ([Id],
[FirstName], [LastName], [City], [Country], [Phone]) VALUES (@Id, @FirstName, @LastName,
@City, @Country, @Phone)" OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Student]" UpdateCommand="UPDATE [Student] SET
[FirstName] = @FirstName, [LastName] = @LastName, [City] = @City, [Country] = @Country,
[Phone] = @Phone WHERE [Id] = @original_Id AND (([FirstName] = @original_FirstName) OR
([FirstName] IS NULL AND @original_FirstName IS NULL)) AND (([LastName] =
@original_LastName) OR ([LastName] IS NULL AND @original_LastName IS NULL)) AND
(([City] = @original_City) OR ([City] IS NULL AND @original_City IS NULL)) AND (([Country]
= @original_Country) OR ([Country] IS NULL AND @original_Country IS NULL)) AND
(([Phone] = @original_Phone) OR ([Phone] IS NULL AND @original_Phone IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_Country" Type="String" />
<asp:Parameter Name="original_Phone" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Id" Type="Int32" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Country" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Country" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_Country" Type="String" />
<asp:Parameter Name="original_Phone" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
}
protected void Button1_Click(object sender, EventArgs e)
{
string connStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection con=new SqlConnection(connStr);
SqlDataAdapter objDa=new SqlDataAdapter();
DataSet objDs= new DataSet();
using (SqlConnection objConn = new SqlConnection(connStr))
{
SqlCommand objCmd = new SqlCommand("Select * from Student", objConn);
objCmd.CommandType = CommandType.Text;
objDa.SelectCommand = objCmd;
objDa.Fill(objDs, "Product");
GridView1.DataSource = objDs.Tables[0];
GridView1.DataBind();
}
}
}
Web.config:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="Data
Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated
Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.8.1" />
<httpRuntime targetFramework="4.8.1" />
</system.web>
</configuration>
OUTPUT:
PRACTICAL NO: 7
Aim:: Write the program for the following.
a.) Create a web application for inserting and deleting records from a database. (Using
Execute-Non Query).
Design Views:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="Pract7a.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Enter Student
Id:
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
<br />
Enter Student FirstName: <asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
<br />
Enter Student LastName: <asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox>
<br />
Enter Student City:
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
Enter Student Country:
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<br />
Enter Student Phone:
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Insert Record" />
&nbs
p; &n
bsp;
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Delete Record" />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Result:"></asp:Label>
</div>
</form>
</body>
</html>
WebForm1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Pract7a
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Design Views:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id"
/>
<asp:BoundField DataField="First Name" HeaderText="First Name"
SortExpression="First Name" />
<asp:BoundField DataField="Last Name" HeaderText="Last Name" SortExpression="Last
Name" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country"
/>
<asp:BoundField DataField="Phone " HeaderText="Phone " SortExpression="Phone " />
<asp:CommandField ButtonType="Button" HeaderText="EDIT" ShowEditButton="True"
ShowHeader="True" />
<asp:CommandField ButtonType="Button" HeaderText="DELETE"
ShowDeleteButton="True" ShowHeader="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues" ConnectionString="<%$
ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [Student] WHERE
[Id] = @original_Id AND (([First Name] = @original_First_Name) OR ([First Name] IS NULL
AND @original_First_Name IS NULL)) AND (([Last Name] = @original_Last_Name) OR ([Last
Name] IS NULL AND @original_Last_Name IS NULL)) AND (([City] = @original_City) OR
([City] IS NULL AND @original_City IS NULL)) AND (([Country] = @original_Country) OR
([Country] IS NULL AND @original_Country IS NULL)) AND (([Phone ] = @original_Phone_)
OR ([Phone ] IS NULL AND @original_Phone_ IS NULL))" InsertCommand="INSERT INTO
[Student] ([Id], [First Name], [Last Name], [City], [Country], [Phone ]) VALUES (@Id,
@First_Name, @Last_Name, @City, @Country, @Phone_)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [Student]"
UpdateCommand="UPDATE [Student] SET [First Name] = @First_Name, [Last Name] =
@Last_Name, [City] = @City, [Country] = @Country, [Phone ] = @Phone_ WHERE [Id] =
@original_Id AND (([First Name] = @original_First_Name) OR ([First Name] IS NULL AND
@original_First_Name IS NULL)) AND (([Last Name] = @original_Last_Name) OR ([Last Name]
IS NULL AND @original_Last_Name IS NULL)) AND (([City] = @original_City) OR ([City] IS
NULL AND @original_City IS NULL)) AND (([Country] = @original_Country) OR ([Country] IS
NULL AND @original_Country IS NULL)) AND (([Phone ] = @original_Phone_) OR ([Phone ] IS
NULL AND @original_Phone_ IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_First_Name" Type="String" />
<asp:Parameter Name="original_Last_Name" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_Country" Type="String" />
<asp:Parameter Name="original_Phone_" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Id" Type="Int32" />
<asp:Parameter Name="First_Name" Type="String" />
<asp:Parameter Name="Last_Name" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Country" Type="String" />
<asp:Parameter Name="Phone_" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="First_Name" Type="String" />
<asp:Parameter Name="Last_Name" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Country" Type="String" />
<asp:Parameter Name="Phone_" Type="String" />
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_First_Name" Type="String" />
<asp:Parameter Name="original_Last_Name" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_Country" Type="String" />
<asp:Parameter Name="original_Phone_" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
OUTPUT:
Design Views:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
DataKeyNames="Id" DataSourceID="SqlDataSource1">
<EditItemTemplate>
Id:
<asp:Label ID="IdLabel1" runat="server" Text='<%# Eval("Id") %>' />
<br />
First Name:
<asp:TextBox ID="First_NameTextBox" runat="server" Text='<%# Bind("[First
Name]") %>' />
<br />
Last Name:
<asp:TextBox ID="Last_NameTextBox" runat="server" Text='<%# Bind("[Last
Name]") %>' />
<br />
City:
<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
<br />
Phone No:
<asp:TextBox ID="Phone_NoTextBox" runat="server" Text='<%# Bind("[Phone
No]") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
Id:
<asp:TextBox ID="IdTextBox" runat="server" Text='<%# Bind("Id") %>' />
<br />
First Name:
<asp:TextBox ID="First_NameTextBox" runat="server" Text='<%# Bind("[First
Name]") %>' />
<br />
Last Name:
<asp:TextBox ID="Last_NameTextBox" runat="server" Text='<%# Bind("[Last
Name]") %>' />
<br />
City:
<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
<br />
Phone No:
<asp:TextBox ID="Phone_NoTextBox" runat="server" Text='<%# Bind("[Phone
No]") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
Id:
<asp:Label ID="IdLabel" runat="server" Text='<%# Eval("Id") %>' />
<br />
First Name:
<asp:Label ID="First_NameLabel" runat="server" Text='<%# Bind("[First
Name]") %>' />
<br />
Last Name:
<asp:Label ID="Last_NameLabel" runat="server" Text='<%# Bind("[Last Name]")
%>' />
<br />
City:
<asp:Label ID="CityLabel" runat="server" Text='<%# Bind("City") %>' />
<br />
Phone No:
<asp:Label ID="Phone_NoLabel" runat="server" Text='<%# Bind("[Phone No]")
%>' />
<br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit" />
<asp:LinkButton ID="DeleteButton" runat="server"
CausesValidation="False" CommandName="Delete" Text="Delete" />
<asp:LinkButton ID="NewButton" runat="server"
CausesValidation="False" CommandName="New" Text="New" />
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues" ConnectionString="<%$
ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [Student]
WHERE [Id] = @original_Id AND (([First Name] = @original_First_Name) OR ([First
Name] IS NULL AND @original_First_Name IS NULL)) AND (([Last Name] =
@original_Last_Name) OR ([Last Name] IS NULL AND @original_Last_Name IS NULL))
AND (([City] = @original_City) OR ([City] IS NULL AND @original_City IS NULL))
AND (([Phone No] = @original_Phone_No) OR ([Phone No] IS NULL AND
@original_Phone_No IS NULL))" InsertCommand="INSERT INTO [Student] ([Id], [First
Name], [Last Name], [City], [Phone No]) VALUES (@Id, @First_Name, @Last_Name,
@City, @Phone_No)" OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Student]" UpdateCommand="UPDATE [Student] SET
[First Name] = @First_Name, [Last Name] = @Last_Name, [City] = @City, [Phone No] =
@Phone_No WHERE [Id] = @original_Id AND (([First Name] = @original_First_Name)
OR ([First Name] IS NULL AND @original_First_Name IS NULL)) AND (([Last Name] =
@original_Last_Name) OR ([Last Name] IS NULL AND @original_Last_Name IS NULL))
AND (([City] = @original_City) OR ([City] IS NULL AND @original_City IS NULL))
AND (([Phone No] = @original_Phone_No) OR ([Phone No] IS NULL AND
@original_Phone_No IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_First_Name" Type="String" />
<asp:Parameter Name="original_Last_Name" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_Phone_No" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Id" Type="Int32" />
<asp:Parameter Name="First_Name" Type="String" />
<asp:Parameter Name="Last_Name" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Phone_No" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="First_Name" Type="String" />
<asp:Parameter Name="Last_Name" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Phone_No" Type="String" />
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_First_Name" Type="String" />
<asp:Parameter Name="original_Last_Name" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_Phone_No" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
OUTPUT:
After clicking Edit: