1.write A Program To Perform All Arithmatic Operations: Date:-22/09/2015
1.write A Program To Perform All Arithmatic Operations: Date:-22/09/2015
1.write A Program To Perform All Arithmatic Operations: Date:-22/09/2015
NET Tasks :-
Date:- 22/09/2015
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
 
; &nbs
p;
<asp:Label ID="lbldisplay" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
.Cs Code:-
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)
{
lbldisplay.Text ="Adition is" +( Convert.ToInt32(T1.Text) +
Convert.ToInt32(T2.Text)).ToString();
}
protected void Button3_Click(object sender, EventArgs e)
{
lbldisplay.Text = "Sutraction is "+(Convert.ToInt32(T1.Text) -
Convert.ToInt32(T2.Text)).ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
lbldisplay.Text = "Multiplication is "+(Convert.ToInt32(T1.Text) *
Convert.ToInt32(T2.Text)).ToString();
}
protected void Button4_Click(object sender, EventArgs e)
{
lbldisplay.Text ="Division is"+ (Convert.ToInt32(T1.Text) /
Convert.ToInt32(T2.Text)).ToString();
}
}
.aspx Code
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 51%;
}
.auto-style3 {
width: 747px;
}
.auto-style4 {
width: 770px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
.cs code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void Button2_Click(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int n = Convert.ToInt32(T1.Text), sum = 0, r, m;
m = n;
while (n > 0)
{
r = n % 10;
sum = sum + (r * r * r);
n = n / 10;
}
if (sum == m)
{
lbldisplay.Text = "This is Armstrong Number";
}
else
{
lbldisplay.Text = "This is Not Armstrong";
}
}
}
.aspx code
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 51%;
}
.auto-style3 {
width: 747px;
}
.auto-style4 {
width: 770px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
int i, n = Convert.ToInt32(T1.Text);
long f = 1;
for (i = 1; i <= n; i++)
{
f = f * i;
}
lbldisplay.Text = "factorial is" + f.ToString();
}
}
.aspx code
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 41%;
height: 92px;
margin-right: 0px;
}
.auto-style3 {
width: 88px;
}
.auto-style4 {
width: 256px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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)
{
series();
}
int n, f1 = 0, f2 = 1, f3 = 0;
public void series()
{
Console.WriteLine("Enter Any Limit");
n = Convert.ToInt32(T2.Text);
Response.Write(f1+" ");
while(f3<n)
{
f3 = f1 + f2;
Response.Write(f3 + ",");
f1 = f2;
f2 = f3;
}
}
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 67%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void Submit_Click(object sender, EventArgs e)
{
int n = Convert.ToInt32(T1.Text), rev=0, r,m;
m = n;
while (n > 0)
{
r = n % 10;
rev = (rev * 10) + r;
n = n / 10;
}
if (rev == m)
{
lbldisplay.Text = "This is a palindrome Number";
}
else
{
lbldisplay.Text = "This is not a palinddrome";
}
}
}
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 45%;
}
</style>
</head>
<body style="height: 84px; width: 807px">
<form id="form1" runat="server">
<table class="auto-style1" style="background-color: #FF3300; height: 78px;">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Enter Any
Number"></asp:Label>
</td>
<td>
<asp:TextBox ID="T1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbldisplay" runat="server"></asp:Label>
</td>
<td>
<asp:Button ID="Button2" runat="server" Text="Submit"
ForeColor="Blue" OnClick="Button2_Click" />
</td>
</tr>
</table>
<div>
</div>
</form>
</body>
</html>
.cs code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void Button2_Click(object sender, EventArgs e)
{
int n = Convert.ToInt32(T1.Text), i, sum = 0,D;
D=2*n;
for (i = 1; i <= n; i++)
{
if (n % i == 0)
{
sum = sum + i;
}
}
if(sum==D)
{
lbldisplay.Text="This is a Perfect Number";
}
else
{
lbldisplay.Text="This is not a Perfect Number";
}
}
}
.aspx code :-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 49%;
}
.auto-style8 {
height: 23px;
}
.auto-style9 {
width: 246px;
}
.auto-style10 {
height: 23px;
width: 246px;
}
.auto-style11 {
width: 246px;
height: 30px;
}
.auto-style12 {
height: 30px;
}
</style>
</head>
<body>
<form id="form3" runat="server">
<div>
</div>
<table class="auto-style1" style="background-color: #996633; height: 88px;">
<tr>
<td class="auto-style9">
<asp:Label ID="Label8" runat="server" Text="Enter Starting
Value"></asp:Label>
</td>
<td>
<asp:TextBox ID="T1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style10">
<asp:Label ID="Label9" runat="server" Text="Enter Ending
Value"></asp:Label>
</td>
<td class="auto-style8">
<asp:TextBox ID="T2" runat="server" Height="22px"
Width="139px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style11">
</td>
<td class="auto-style12">
<asp:Button ID="Submit1" runat="server" Text="Submit"
ForeColor="#00CC00" OnClick="Submit_Click" />
</td>
</tr>
</table>
</form>
</body>
</html>
.cs code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void Submit_Click(object sender, EventArgs e)
{
int i, j, n1=Convert.ToInt32(T1.Text), n2=Convert.ToInt32(T2.Text), cnt = 0;
}
}
.aspx code :-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 55%;
height: 59px;
}
.auto-style3 {
width: 487px;
}
.auto-style4 {
width: 1055px;
}
.auto-style5 {
width: 1055px;
height: 26px;
}
.auto-style6 {
width: 487px;
height: 26px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
int i, n = Convert.ToInt32(T2.Text), count = 0;
for (i = 1; i <= n; i++)
{
if (n % i == 0)
{
count++;
}
}
if (count == 2)
{
lbldisplay.Text = "This is a prime number";
}
else
{
lbldisplay.Text = "This is not a prime number";
}
}
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 52%;
height: 85px;
}
.auto-style2 {
width: 379px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table align="center" class="auto-style1" style="background-color: #66FF99">
<tr>
<td class="auto-style2">
<asp:Label ID="Label5" runat="server" Text="Enter The
String"></asp:Label>
</td>
<td>
<asp:TextBox ID="T1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="lbldisplay" runat="server"></asp:Label>
</td>
<td>
<asp:Button ID="btnsubmit" runat="server" ForeColor="#FF0066"
OnClick="btnsubmit_Click" Text="Submit" />
</td>
</tr>
</table>
</form>
</body>
</html>
.cs code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
string s=T1.Text;
lbldisplay.Text=(stringtools.alphabet(s));
}
}
public static class stringtools
{
public static string alphabet(string s)
{
char[] a=s.ToCharArray();
Array.Sort(a);
return new string(a);
}
}
.aspx code :-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 195px;
}
</style>
</head>
<body style="height: 91px; width: 446px">
<form id="form1" runat="server">
<table class="auto-style1" style="background-color: #990000">
<tr>
<td class="auto-style2">
<asp:Label ID="Label1" runat="server" Text="Enter
string"></asp:Label>
</td>
<td>
<asp:TextBox ID="T1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="lbldisplay" runat="server"></asp:Label>
</td>
<td>
<asp:Button ID="Submit" runat="server" OnClick="Submit_Click"
Text="Submit" ForeColor="#339933" />
</td>
</tr>
</table>
</form>
</body>
</html>
.cs code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void Submit_Click(object sender, EventArgs e)
{
int i;string srev = ""; string s = T1.Text;
for (i=s.Length-1;i>=0;i--)
{
srev = srev + s[i];
}
if (srev==s)
{
lbldisplay.Text = "This is Palindome";
}
else
{
lbldisplay.Text = "This is not a palindrome";
}
}
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 65%;
}
.auto-style2 {
width: 261px;
}
.auto-style3 {
width: 261px;
height: 52px;
}
.auto-style4 {
height: 52px;
width: 312px;
}
.auto-style5 {
width: 312px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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)
{
int i;string srev = ""; string s = T1.Text;
for (i = s.Length - 1; i >= 0; i--)
{
srev = srev+ s[i];
}
lbldisplay.Text = srev.ToString();
}
}
Login Task
Home Page :-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="background-color: #000000;margin-bottom:100px">
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
<asp:Label ID="Label2" runat="server" Font-Size="XX-Large" ForeColor="White"
Text="Home Page"></asp:Label>
</div>
<div>
</div>
<div style="background-color: #000000;margin-top:310px">
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
<asp:Label ID="Label13" runat="server" ForeColor="White" Text="Developed By
Megafore Tech , Hyd"></asp:Label>
<br />
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
<asp:Label ID="Label14" runat="server" ForeColor="White" Text="Copyrights
Belongs To Megafore Technologies"></asp:Label>
</div>
</form>
</body>
</html>
.cs code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void lbtnlogout_Click(object sender, EventArgs e)
{
Response.Redirect("Login.aspx");
}
}
Login Page :-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 65%;
height: 82px;
}
.auto-style2 {
width: 112px;
}
.auto-style3 {
width: 320px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="background-color: #000000;margin-bottom:100px">
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
 
;
<asp:Label ID="Label3" runat="server" Font-Size="XX-Large" ForeColor="White"
Text="Login Here"></asp:Label>
</div>
<div>
<table align="center" class="auto-style1">
<tr>
<td class="auto-style2">
<asp:Label ID="Label1" runat="server" Text="Enter User
Name"></asp:Label>
</td>
<td class="auto-style3">
<asp:TextBox ID="txtusername" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="txtusername" EnableClientScript="False"
ErrorMessage="Please Enter Your User Name" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label2" runat="server" Text="Enter
Passsword"></asp:Label>
</td>
<td class="auto-style3">
<asp:TextBox ID="txtpassword" runat="server"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server" ControlToValidate="txtpassword" EnableClientScript="False"
ErrorMessage="Please Enter Your Password" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td class="auto-style3">
<asp:Button ID="btnlogin" runat="server" OnClick="btnlogin_Click"
Text="Login" />
<br />
<asp:CheckBox ID="CheckBox1" runat="server" Text="Remember Me" />
<br />
<asp:LinkButton ID="LinkButton1" runat="server"
OnClick="LinkButton1_Click">Register Here</asp:LinkButton>
</td>
</tr>
</table>
</div>
<div style="background-color: #000000;margin-top:225px">
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
 
;
<asp:Label ID="Label12" runat="server" ForeColor="White" Text="Developed By
Megafore Tech , Hyd"></asp:Label>
<br />
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
 
;
<asp:Label ID="Label13" runat="server" ForeColor="White" Text="Copy Rghts Belongs
To Megafore Technologies"></asp:Label>
</div>
</form>
</body>
</html>
.cs code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void btnlogin_Click(object sender, EventArgs e)
{
if(Page.IsValid==true)
Response.Redirect("Home.aspx");
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("Registration.aspx");
}
}
Registration Page :-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 67%;
height: 187px;
}
.auto-style2 {
width: 335px;
}
.auto-style3 {
width: 505px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="background-color: #000000;margin-bottom:100px">
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
 
;
<asp:Label ID="Label10" runat="server" Font-Size="XX-Large" ForeColor="White"
Text="Register Here"></asp:Label>
</div>
<div>
<table align="center" class="auto-style1">
<tr>
<td class="auto-style2">
<asp:Label ID="Label1" runat="server" Text="Enter First
Nme"></asp:Label>
</td>
<td class="auto-style3">
<asp:TextBox ID="txtfirstname" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="txtfirstname" EnableClientScript="False"
ErrorMessage="Please Enter First Name" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label2" runat="server" Text="Enter Last
Name"></asp:Label>
</td>
<td class="auto-style3">
<asp:TextBox ID="txtlastname" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server" ControlToValidate="txtlastname" EnableClientScript="False"
ErrorMessage="Please Enter Last Name" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label3" runat="server" Text="Enter
Password"></asp:Label>
</td>
<td class="auto-style3">
<asp:TextBox ID="txtpassword" runat="server"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3"
runat="server" ControlToValidate="txtpassword" EnableClientScript="False"
ErrorMessage="Please Enter Pasword" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">Enter Password</td>
<td class="auto-style3">
<asp:TextBox ID="txtreenterpassword" runat="server"
TextMode="Password"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="txtpassword" ControlToValidate="txtreenterpassword"
EnableClientScript="False" ErrorMessage="Passwords Should Be Same"
ForeColor="Red"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label4" runat="server" Text="Select
Gender"></asp:Label>
</td>
<td class="auto-style3">
<asp:RadioButton ID="rbtnmale" runat="server" GroupName="gender"
Text="Male" />
<asp:RadioButton ID="rbtnFemale" runat="server" GroupName="gender"
Text="Female" />
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label5" runat="server" Text="Enter Email
ID"></asp:Label>
</td>
<td class="auto-style3">
<asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4"
runat="server" ControlToValidate="txtemail" EnableClientScript="False"
ErrorMessage="Please Enter Email id" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="txtemail" EnableClientScript="False"
ErrorMessage="Enter Correct Email ID" ForeColor="Red" ValidationExpression="\w+([-
+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label6" runat="server" Text="Enter Phone
Number"></asp:Label>
</td>
<td class="auto-style3">
<asp:TextBox ID="txtphonenumber" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5"
runat="server" ControlToValidate="txtphonenumber" EnableClientScript="False"
ErrorMessage="Please Enter Password" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label7" runat="server" Text="Select
Qualification"></asp:Label>
</td>
<td class="auto-style3">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Selected="True">B.Tech</asp:ListItem>
<asp:ListItem>M.Tech</asp:ListItem>
<asp:ListItem>MCA</asp:ListItem>
<asp:ListItem>MBA</asp:ListItem>
<asp:ListItem>BE</asp:ListItem>
<asp:ListItem>ME</asp:ListItem>
<asp:ListItem>BSC</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label8" runat="server" Text="Course"></asp:Label>
</td>
<td class="auto-style3">
<asp:CheckBox ID="chknet" runat="server" Text=".NET" />
<asp:CheckBox ID="chkjava" runat="server" Text="JAVA" />
<br />
<asp:CheckBox ID="chkoracle" runat="server" Text="Oracle" />
<asp:CheckBox ID="chkandroid" runat="server" Text="Android" />
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label9" runat="server" Text="Select
Batches"></asp:Label>
</td>
<td class="auto-style3">
<asp:RadioButton ID="rbtnbatcha" runat="server" GroupName="tmings"
Text="Batch A" />
<asp:RadioButton ID="rbtnbatchb" runat="server" GroupName="tmings"
Text="Batch B" />
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Button ID="brnreset" runat="server" OnClick="brnreset_Click"
Text="Reset" />
 
; </td>
<td class="auto-style3"> <asp:Button ID="btnsubmit0" runat="server"
OnClick="btnsubmit_Click" Text="Submit" />
 
; &nbs
p;
<asp:LinkButton ID="lbtnlogin" runat="server"
OnClick="lbtnlogin_Click">You Can Also Login Here</asp:LinkButton>
</td>
</tr>
</table>
</div>
<div style="background-color: #000000;margin-top:70px">
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
<asp:Label ID="Label11" runat="server" ForeColor="White" Text="Developed By
Megafore Tech , Hyd"></asp:Label>
<br />
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
<asp:Label ID="Label12" runat="server" ForeColor="White" Text="Copyrights Belongs
To Megafore Technologies"></asp:Label>
</div>
</form>
</body>
</html>
.cs code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
if (Page.IsValid == true)
{
Response.Redirect("submit.aspx");
}
}
protected void lbtnlogin_Click(object sender, EventArgs e)
{
Response.Redirect("Login.aspx");
}
protected void brnreset_Click(object sender, EventArgs e)
{
txtfirstname.Text = "";
txtlastname.Text="";
txtemail.Text="";
txtpassword.Text="";
txtphonenumber.Text = "";
txtreenterpassword.Text = "";
rbtnFemale.Checked = false;
rbtnmale.Checked = false;
chkandroid.Checked = false;
chkjava.Checked = false;
chknet.Checked = false;
chkoracle.Checked = false;
rbtnbatcha.Checked = false;
rbtnbatchb.Checked = false;
}
}
Submitted Page :-
.aspx code :-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="background-color: #000000;margin-bottom:100px">
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
 
;
<asp:Label ID="Label2" runat="server" Font-Size="XX-Large" ForeColor="White"
Text="Acknowledgement"></asp:Label>
</div>
<div>
</div>
</form>
</body>
</html>
.cs code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void lbtnlogin1_Click(object sender, EventArgs e)
{
Response.Redirect("Login.aspx");
}
}
.cs code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
}
Contact Us:-
.aspx code:-
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="Contact Us.aspx.cs" Inherits="Contact_Us" %>
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
 
; &nbs
p; &nb
sp;
<asp:Label ID="Label5" runat="server" Font-Size="XX-Large" Text="Contact
Us"></asp:Label>
</p>
<p>
<asp:Label ID="Label4" runat="server" Text="Megafore Technologies"></asp:Label>
</p>
<p>
Plot No:50</p>
<p>
Opp: Madhapur Petrol Bunk</p>
<p>
4th-Floor ,V-square Building</p>
<p>
Madhapur,Hi-Techcity,Telangana,India</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
</asp:Content>
.cs code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
}
Home Page :-
.aspx code:-
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" %>
 
; &nbs
p; &nb
sp; &n
bsp;
<asp:Image ID="Image1" runat="server" Height="292px"
ImageUrl="~/imags/B6QuwGqCcAAUC8j.jpg" Width="474px" />
</p>
</asp:Content>
.cs code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
}
Login Page:-
.aspx code:-
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p>
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
<br />
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
 
; &nbs
p; &nb
sp;
<asp:Label ID="Label4" runat="server" Font-Size="XX-Large" Text="Login"></asp:Label>
</p>
<form Id="f1">
<table align="center" class="auto-style1">
<tr>
<td class="auto-style2">
<asp:Label ID="Label5" runat="server" Text="Enter User name"></asp:Label>
</td>
<td>
<asp:TextBox ID="t1" runat="server" onblur="fadd()"></asp:TextBox>
<asp:Label ID="l1" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label6" runat="server" Text="Enter Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtpassword" runat="server" ></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Button ID="btnsubmit" runat="server" Text="Submit"
OnClientClick="javascript:return fadd();" OnClick="btnsubmit_Click"/>
</td>
<td>
<asp:LinkButton ID="lbtnnewregster" runat="server"
OnClick="lbtnnewregster_Click">Register Here</asp:LinkButton>
</td>
</tr>
</table>
</form>
<p style="height: 10px; width: 1250px">
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
</asp:Content>
.cs code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void lbtnnewregster_Click(object sender, EventArgs e)
{
Response.Redirect("New Registraton.aspx");
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
Response.Redirect("Home.aspx");
}
}
Master Page:-
.aspx code:-
<%@ 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>
<div style="background-color: #000000">
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp; <asp:Label ID="Label1" runat="server" Text="Megafore Technologies"
Font-Size="XX-Large" ForeColor="White"></asp:Label>
<br />
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
<asp:Label ID="Label4" runat="server" ForeColor="White" Text="An Iso 9001-
2008 Certified Company"></asp:Label>
<br />
<br />
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" Width="250px"
ForeColor="White">
<Items>
<asp:MenuItem Text="Home" Value="Home"
NavigateUrl="~/Home.aspx"></asp:MenuItem>
<asp:MenuItem Text="About Us" Value="About Us" NavigateUrl="~/About
Us.aspx"></asp:MenuItem>
<asp:MenuItem Text="Contact Us" Value="Contact Us"
NavigateUrl="~/Contact Us.aspx"></asp:MenuItem>
<asp:MenuItem Text="Login" Value="Login"
NavigateUrl="~/Login.aspx"></asp:MenuItem>
</Items>
</asp:Menu>
<br />
</div>
<p>
<br />
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
</asp:ContentPlaceHolder>
</div>
<div style="background-color: #000000">
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
 
;
<asp:Label ID="Label2" runat="server" Text="Developed By "
ForeColor="White"></asp:Label>
<asp:LinkButton ID="LinkButton1" runat="server" ForeColor="White">Megafore
Technologies</asp:LinkButton>
<br />
 
; &nbs
p; &nb
sp; &n
bsp; &
nbsp;
 
;
<asp:Label ID="Label3" runat="server" Text="copyrights Reserved By Megafore
Technologies" ForeColor="White"></asp:Label>
</div>
</form>
</body>
</html>
.cs code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("home.aspx");
}
}
.cs code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
Response.Redirect("Login.aspx");
}
}
Task On Data Base :-
Connection oriented architecture 1st Method:-
Bus table:-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Table_Buses.aspx.cs"
Inherits="Table_Buses" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 43%;
height: 182px;
}
.auto-style2 {
width: 226px;
}
</style>
</head>
<body>
<form id="form2" runat="server">
<div>
</div>
</form>
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btninsert_Click(object sender, EventArgs e)
{
string s = "insert into buses values(" + txtbusid.Text + ",'" + txtbusname.Text +
"'," + txtseatcapacity.Text + "," + txtbusmilage.Text + ",'" + txtbustype.Text + "')";
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row(s) Effected";
}
protected void btnupdate_Click(object sender, EventArgs e)
{
string s = "update buses set
bus_company='TATA',seat_capacity=50,bus_miilage=20,bus_type='AC' where bus_id=" +
txtbusid.Text;
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Effected";
}
protected void btndelete_Click(object sender, EventArgs e)
{
string s = "delete buses where bus_id=" +txtbusid.Text;
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Deleted";
}
protected void btnclear_Click(object sender, EventArgs e)
{
txtbusid.Text = "";
txtbusmilage.Text = "";
txtbusname.Text = "";
txtbustype.Text = "";
txtseatcapacity.Text = "";
}
}
Table Company:-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Table_Company.aspx.cs"
Inherits="Table_Company" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 43%;
height: 182px;
}
.auto-style2 {
width: 226px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btninsert_Click(object sender, EventArgs e)
{
string s = "insert into Company values(" + txtcompanyid.Text + ",'" +
txtcompanyname.Text + "','" + txtcompanytype.Text + "','" + txtcompanyestd.Text + "','" +
txtcompanyaddress.Text + "')";
//string s = "insert into company values(@pid,@pname,@ptype,@pestd,@paddress)";
cmd = new SqlCommand(s, con);
//cmd.Parameters.AddWithValue("@pid", txtcompanyid.Text);
//cmd.Parameters.AddWithValue("@pname", txtcompanyname.Text);
//cmd.Parameters.AddWithValue("@ptype", txtcompanytype.Text);
//cmd.Parameters.AddWithValue("@pestd", txtcompanyestd.Text);
//cmd.Parameters.AddWithValue("@paddress", txtcompanyaddress.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row(s) Effected";
}
protected void btnupdate_Click(object sender, EventArgs e)
{
string s = "update company set
com_name='capgemini',com_type='services',com_estd=2006,com_address='hyd' where com_id=" +
txtcompanyid.Text;
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Effected";
}
protected void btndelete_Click(object sender, EventArgs e)
{
string s="delete company where com_id="+txtcompanyid.Text;
cmd = new SqlCommand(s,con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Deleted";
}
protected void btnclear_Click(object sender, EventArgs e)
{
txtcompanyid.Text = "";
txtcompanyname.Text = "";
txtcompanytype.Text = "";
txtcompanyestd.Text = "";
txtcompanyaddress.Text = "";
}
}
Table Employs :-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Table_Employee.aspx.cs"
Inherits="Table_Employee" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 43%;
height: 182px;
}
.auto-style2 {
width: 226px;
}
</style>
</head>
<body>
<form id="form2" runat="server">
<div>
</div>
</form>
<div>
</div>
</body>
</html>
.cs code:-
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;
}
protected void btninsert_Click(object sender, EventArgs e)
{
string s = "insert into emp values(" + txtempid.Text + ",'" + txtename.Text +
"','" + txtdesignation.Text + "'," + txtdoj.Text + "," + txtsalary.Text + "," +
txtdeptno.Text + ")";
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row(s) Effected";
}
protected void btnupdate_Click(object sender, EventArgs e)
{
string s = "update emp set
emp_name='arun',emp_designation='Developer',emp_doj=2006,emp_salary=1000,emp_deptno=6
where emp_id=" + txtempid.Text;
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Effected";
}
protected void btndelete_Click(object sender, EventArgs e)
{
string s = "delete emp where emp_id=" + txtempid.Text;
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Deleted";
}
protected void btnclear_Click(object sender, EventArgs e)
{
txtempid.Text = "";
txtename.Text = "";
txtdesignation.Text = "";
txtdoj.Text = "";
txtsalary.Text = "";
txtdeptno.Text = "";
}
}
Table Manager:-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 43%;
height: 182px;
}
.auto-style2 {
width: 226px;
}
</style>
</head>
<body>
<form id="form2" runat="server">
<div>
</div>
</form>
</form>
</body>
</html>
.cs file:-
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;
}
protected void btninsert_Click(object sender, EventArgs e)
{
string s = "insert into manager values(" + txtmanagerid.Text + ",'" +
txtmanagername.Text + "'," + txtmanagerdoj.Text + "," + txtmanagersalary.Text + "," +
txtmanagerdeptno.Text + ")";
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row(s) Effected";
}
protected void btnupdate_Click(object sender, EventArgs e)
{
string s = "update manager set
manager_name='arun',manager_doj=2015,manager_salary=10000,manager_deptno=1 where
manager_id=" + txtmanagerid.Text;
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Effected";
}
protected void btndelete_Click(object sender, EventArgs e)
{
string s = "delete manager where manager_id=" + txtmanagerid.Text;
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Deleted";
}
protected void btnclear_Click(object sender, EventArgs e)
{
txtmanagerid.Text = "";
txtmanagername.Text = "";
txtmanagerdoj.Text = "";
txtmanagersalary.Text = "";
}
}
Table Bus:-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 43%;
height: 182px;
}
.auto-style2 {
width: 226px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
Table Company :-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 43%;
height: 182px;
}
.auto-style2 {
width: 226px;
}
</style>
</head>
<body>
<form id="form2" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btnedt_Click(object sender, EventArgs e)
{
string s = "select *from company where com_id=" + txtcompanyid.Text;
cmd = new SqlCommand(s, con);
con.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
lblResult.Text = "";
txtcompanyid.Text = dr[0].ToString();
txtcompanyname.Text = dr[1].ToString();
txtcompanytype.Text = dr[2].ToString();
txtcompanyestd.Text = dr[3].ToString();
txtcompanyaddress.Text = dr[4].ToString();
}
else
{
txtcompanyaddress.Text = "";
txtcompanyestd.Text = "";
txtcompanyname.Text = "";
txtcompanytype.Text = "";
lblResult.Text = "Records no found";
}
}
protected void btninsert_Click(object sender, EventArgs e)
{
string s = "update company set
com_name='capgemini',com_type='services',com_estd=2006,com_address='hyd' where com_id=" +
txtcompanyid.Text;
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Effected";
}
protected void btndelete_Click(object sender, EventArgs e)
{
string s = "delete company where com_id=" + txtcompanyid.Text;
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Deleted";
}
}
Table Employee :-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style2 {
width: 226px;
}
.auto-style1 {
width: 43%;
height: 182px;
}
</style>
</head>
<body>
<form id="form2" runat="server">
<div>
</div>
</form>
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btninsert_Click(object sender, EventArgs e)
{
txtename.Text = "";
txtsalary.Text = "";
lblResult.Text="REcords not found";
}
}
}
Table manager:-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style2 {
width: 226px;
}
.auto-style1 {
width: 43%;
height: 182px;
}
</style>
</head>
<body>
<form id="form2" runat="server">
<div>
</div>
</form>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btnedit_Click(object sender, EventArgs e)
{
string s = "select *from manager where manager_id=" + txtmanagerid.Text;
cmd = new SqlCommand(s, con);
con.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
lblResult.Text = "";
txtmanagerid.Text = dr[0].ToString();
txtmanagername.Text = dr[1].ToString();
txtmanagerdoj.Text = dr[2].ToString();
txtmanagersalary.Text = dr[3].ToString();
txtmanagerdeptno.Text = dr[4].ToString();
}
else
{
txtmanagerdeptno.Text = "";
txtmanagerdoj.Text = "";
txtmanagername.Text = "";
txtmanagersalary.Text = "";
lblResult.Text = "Records Not Found";
}
}
protected void btninsert_Click(object sender, EventArgs e)
{
string s = "update manager set
manager_name='arun',manager_doj=2015,manager_salary=10000,manager_deptno=1 where
manager_id=" + txtmanagerid.Text;
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Effected";
}
protected void btndelete_Click(object sender, EventArgs e)
{
string s = "delete company where manager_id=" + txtmanagerid.Text;
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Deleted";
}
}
Working With Strored Procedures:-
Customer table:-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 43%;
height: 157px;
}
.auto-style2 {
width: 267px;
}
</style>
</head>
<body>
<form id="form2" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btnsave_Click(object sender, EventArgs e)
{
con.Open();
cmd = new SqlCommand("Inscust", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Cid", Convert.ToInt32(txtCid.Text));
cmd.Parameters.AddWithValue("@Cname", txtCname.Text);
cmd.Parameters.AddWithValue("@CphoneNumber", Convert.ToInt32(txtCnumber.Text));
cmd.Parameters.AddWithValue("@CAddrss", txtCAddress.Text);
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Inserted";
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("Updatecust", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Cid", Convert.ToInt32(txtCid.Text));
cmd.Parameters.AddWithValue("@Cname", txtCname.Text);
cmd.Parameters.AddWithValue("@CphoneNumber", txtCnumber.Text);
cmd.Parameters.AddWithValue("@CAddrss", txtCAddress.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Updated";
}
protected void btndelete_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("Delcust", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Cid",Convert.ToInt32( txtCid.Text));
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Deleted";
}
}
Table Products:-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Products.aspx.cs"
Inherits="Products" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
height: 198px;
width: 645px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btnsave_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("insprod", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Pid", Convert.ToInt32(txtproductid.Text));
cmd.Parameters.AddWithValue("@Pname", txtproductname.Text);
cmd.Parameters.AddWithValue("@Quantity", Convert.ToInt32(txtquantity.Text));
cmd.Parameters.AddWithValue("@untprice", Convert.ToInt32(txtuniprice.Text));
cmd.Parameters.AddWithValue("@PStatus", txtstatus.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblDisplay.Text = i + "ROw (s) Inserted";
}
protected void btnupdate_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("upadateprod", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Pid", Convert.ToInt32(txtproductid.Text));
cmd.Parameters.AddWithValue("@Pname", txtproductname.Text);
cmd.Parameters.AddWithValue("@Quantity", Convert.ToInt32(txtquantity.Text));
cmd.Parameters.AddWithValue("@untprice", Convert.ToInt32(txtuniprice.Text));
cmd.Parameters.AddWithValue("@PStatus", txtstatus.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblDisplay.Text = i + "Row (s) Updated";
}
protected void btndelete_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("Delprod", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Pid", Convert.ToInt32(txtproductid.Text));
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblDisplay.Text = i + "Row (s) Deleted";
}
}
Table sales:-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 45%;
height: 60px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btnSave_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("inssales", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Billno", Convert.ToInt32(txtBillno.Text));
cmd.Parameters.AddWithValue("@Pid", Convert.ToInt32(txtProductid.Text));
cmd.Parameters.AddWithValue("@Pname", txtProductname.Text);
cmd.Parameters.AddWithValue("@TotalPrice", txtTotalprice.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Inserted";
}
protected void btnupdate_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("updatesales", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Billno", Convert.ToInt32(txtBillno.Text));
cmd.Parameters.AddWithValue("@Pid", Convert.ToInt32(txtProductid.Text));
cmd.Parameters.AddWithValue("@Pname", txtProductname.Text);
cmd.Parameters.AddWithValue("@TotalPrice", txtTotalprice.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Updated";
}
protected void btndelete_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("delsales", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Billno", Convert.ToInt32(txtBillno.Text));
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Deleted";
}
}
Table stock:-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
height: 117px;
width: 461px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btnsave_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("insstock", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Pid", Convert.ToInt32(txtproductid.Text));
cmd.Parameters.AddWithValue("@Pname", txtproductname.Text);
cmd.Parameters.AddWithValue("@Pstatus", txtproductstatus.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Inserted";
}
protected void btnupdate_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("updatestock", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Pid", Convert.ToInt32(txtproductid.Text));
cmd.Parameters.AddWithValue("@Pname", txtproductname.Text);
cmd.Parameters.AddWithValue("@Pstatus", txtproductstatus.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Updated";
}
protected void btndelete_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("delstock", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Pid", Convert.ToInt32(txtproductid.Text));
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Deleted";
}
}
DATABASE TASKS :-
Student db:-
Table bus:-
Table school:-
Table student
Table teachers
Table employee
Table manager:-
Table products:-
Table stock :-
Table Employee:-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 207px;
}
</style>
<script>
function fempid()
{
if(form1.txtempid.value==0)
{
document.getElementById("lbl1").innerHTML="enter empid";
else
{
document.getElementById("lbl1").insertHTML="";
}
}
function fempname()
{
if (form1.txtempid.value == 0) {
document.getElementById("lbl2").innerHTML = "enter empname";
else {
document.getElementById("lbl2").insertHTML = "";
}
}
function fempemailaddress()
{
if (form1.txtempid.value == 0)
{
document.getElementById("lbl3").innerHTML = "enter empaddress";
else {
document.getElementById("lbl3").insertHTML = "";
}
}
function fempdeptid() {
if (form1.txtempid.value == 0) {
document.getElementById("lbl4").innerHTML = "enter empdeptid";
else {
document.getElementById("lbl4").insertHTML = "";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2">Enter emp id</td>
<td>
<asp:TextBox ID="txtempid" runat="server" onblur="fempid()">
</asp:TextBox>
 
; &nbs
p;
</td>
</tr>
<tr>
<td class="auto-style2">Enter emp name</td>
<td>
<asp:TextBox ID="txtempname" runat="server" onblur="fempname()">
</asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Enter email address</td>
<td>
<asp:TextBox ID="txtempaddress" runat="server"
onblur="fempemailaddress()">
</asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Enter dept id</td>
<td>
<asp:TextBox ID="txtdeptid" runat="server" onblur="fempdeptid()">
</asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Button ID="btnsave" runat="server" Text="save"
OnClick="btnsave_Click" />
</td>
<td>
<asp:Label ID="lbldisplay" runat="server"></asp:Label>
 
;
</td>
</tr>
<tr>
<td class="auto-style2">
<br />
<asp:DropDownList ID="ddlemployee" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="ddlemployee_SelectedIndexChanged">
</asp:DropDownList>
<br />
<br />
<br />
<br />
<asp:GridView ID="gdvemployeee" runat="server">
</asp:GridView>
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void ddlemployee_SelectedIndexChanged(object sender, EventArgs e)
{
SqlDataAdapter da;
DataSet ds = new DataSet();
da = new SqlDataAdapter("select * from employee_details where emp_did=" +
ddlemployee.SelectedItem.Value,sqlcon);
da.Fill(ds);
gdvemployeee.DataSource = ds;
gdvemployeee.DataBind();
Output:-
Database Output:-
Table Department:-
.aspx code:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td>Enter Department Id</td>
<td>
<asp:TextBox ID="txtDepartmentno" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Enter Department Name</td>
<td>
<asp:TextBox ID="txtDepartmentname" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click"
Text="Save" />
</td>
<td>
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btnSave_Click(object sender, EventArgs e)
{
string s = "insert into department_table values(" + txtDepartmentno.Text + ",'" +
txtDepartmentname.Text + "')";
SqlCommand cmd;
cmd = new SqlCommand(s, sqlcon);
sqlcon.Open();
int i=cmd.ExecuteNonQuery();
sqlcon.Close(); ;
lblMessage.Text = i + "Row (s) Inserted";
}
}
Output:-
Database Out put :-
Countries,States,District Task
Date:- 13/10/2015
Country:-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Counyries.aspx.cs"
Inherits="Counyries" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btnsave_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=.;user
id=sa;password=123456;database=Countries");
SqlCommand cmd;
string s = "insert into Country values(@pcid,@pcname)";
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@pcid", txtcountryid.Text);
cmd.Parameters.AddWithValue("@Pcname", txtcountryname.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblMessage.Text = i + "Row (s) inserted";
}
}
Output:-
Database Output:-
States:-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="States.aspx.cs" Inherits="States"
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<br />
<table class="auto-style1">
<tr>
<td>Enter Country Name</td>
<td>
<asp:DropDownList ID="ddlCountries" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Enter State Id</td>
<td>
<asp:TextBox ID="txtsateid" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Enter State Name</td>
<td>
<asp:TextBox ID="txtstatename" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnsave" runat="server" OnClick="btnsave_Click"
Text="Save" />
</td>
<td>
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
SqlCommand cmd;
string s = "insert into States values(@psid,@psname,@pcid)";
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@psid", txtsateid.Text);
cmd.Parameters.AddWithValue("@psname", txtstatename.Text);
cmd.Parameters.AddWithValue("@pcid", ddlCountries.SelectedItem.Value);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblMessage.Text = i + "Row (s) inserted";
}
}
Output:-
Database output:-
Districts:-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Districts.aspx.cs"
Inherits="Districts" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<table align="center" class="auto-style1">
<tr>
<td>State Name</td>
<td>
<asp:DropDownList ID="ddlstates" runat="server" Height="16px"
Width="124px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Enter District Id</td>
<td>
<asp:TextBox ID="txtdistrictid" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Dstrict Name</td>
<td>
<asp:TextBox ID="txtdistrictname" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnsave" runat="server" OnClick="btnsave_Click"
Text="Save" />
</td>
<td>
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btnsave_Click(object sender, EventArgs e)
{
SqlCommand cmd;
string s = "insert into Dstricts values(@pdid,@pdname,@psid)";
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@pdid", txtdistrictid.Text);
cmd.Parameters.AddWithValue("@pdname", txtdistrictname.Text);
cmd.Parameters.AddWithValue("@psid", ddlstates.SelectedItem.Value);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblMessage.Text = i + "Row (s) Inserted";
}
}
output:-
Database output:-
Comlete form with dropdown lists:-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Customers.aspx.cs"
Inherits="Customers" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 43%;
height: 157px;
}
.auto-style2 {
width: 267px;
}
</style>
</head>
<body>
<form id="form2" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btnsave_Click(object sender, EventArgs e)
{
con.Open();
cmd = new SqlCommand("Inscust", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Cid", Convert.ToInt32(txtCid.Text));
cmd.Parameters.AddWithValue("@Cname", txtCname.Text);
cmd.Parameters.AddWithValue("@CphoneNumber", Convert.ToInt32(txtCnumber.Text));
cmd.Parameters.AddWithValue("@CAddrss", txtCAddress.Text);
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Inserted";
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("Updatecust", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Cid", Convert.ToInt32(txtCid.Text));
cmd.Parameters.AddWithValue("@Cname", txtCname.Text);
cmd.Parameters.AddWithValue("@CphoneNumber", txtCnumber.Text);
cmd.Parameters.AddWithValue("@CAddrss", txtCAddress.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Updated";
}
protected void btndelete_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("Delcust", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Cid",Convert.ToInt32( txtCid.Text));
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblResult.Text = i + "Row (s) Deleted";
}
}
Stored procedure:-
Insert:-
USE [Departmental Stores]
GO
/****** Object: StoredProcedure [dbo].[Inscust] Script Date: 11/03/2015
14:15:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Inscust]
@Cid int,@Cname varchar(50),@CphoneNumber bigint,@CAddrss varchar(50)
as
begin
insert into customer values(@Cid,@Cname ,@CphoneNumber,@CAddrss)
end
update:-
USE [Departmental Stores]
GO
/****** Object: StoredProcedure [dbo].[Updatecust] Script Date:
11/03/2015 14:16:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Updatecust]
@Cid int,@Cname varchar(50),@CphoneNumber bigint,@CAddrss varchar(50)
as
begin
update customer set Cname=@Cname,Cphonenumber=@CphoneNumber,CAddress=@CAddrss
where Cid=@Cid
end
delete:-
USE [Departmental Stores]
GO
/****** Object: StoredProcedure [dbo].[Delcust] Script Date: 11/03/2015
14:17:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Delcust]
@Cid int
as
begin
delete customer where Cid=@Cid
end
Database output:-
Output for update:-
Database output:-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="cusomer.aspx.cs"
Inherits="Repeater" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
gdvqueries.DataSource = ds;
gdvqueries.DataBind();
}
public void gridviewwithsroredprocedure()
{
da = new SqlDataAdapter("selcustomer", con);
gdvstoredprocedure.DataSource = ds;
gdvstoredprocedure.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
repeaterwithqueries();
repeaterwithstoredprocedure();
gridviewwithqueries();
gridviewwithsroredprocedure();
}
}
Out put:-
Task on Gridview with checkbox:-
Date:-20/10/2015
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Gridaspx.aspx.cs"
Inherits="Gridaspx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<Columns>
<asp:TemplateField HeaderText="Empid">
<ItemTemplate>
</asp:GridView>
<br />
<br />
 
;
<asp:Button ID="btnactive" runat="server" Text="Active" OnClick="btnactive_Click"
/>
 
; &nbs
p; &nb
sp;
<asp:Button ID="Btninactive" runat="server" Text="InActive"
OnClick="Btninactive_Click" />
</div>
</form>
</body>
</html>
.cs code:-
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;
Output:-
Task on gridview to find student Percentage:-
Date:-26/10/2015
.aspx code:-
<%@ 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" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:Label ID="lblid" runat="server" Text='<%#Eval("ID")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Name" DataField="Name" />
<asp:BoundField HeaderText="DOB" DataField="DOB" />
<asp:BoundField HeaderText="Class" DataField="Class" />
<%--<asp:TemplateField HeaderText="Unit Type">
<ItemTemplate>
<asp:Label ID="lblunittype" runat="server"
Text='<%#Eval("unit_type") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Telugu">
<ItemTemplate>
<asp:Label ID="lbltelugu" runat="server" Text='<%#Eval("Telugu")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="English">
<ItemTemplate>
<asp:Label ID="lblenglish" runat="server"
Text='<%#Eval("English") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Maths">
<ItemTemplate>
<asp:Label ID="lblmaths" runat="server" Text='<%#Eval("Maths")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Science">
<ItemTemplate>
<asp:Label ID="lblscience" runat="server"
Text='<%#Eval("science") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Social">
<ItemTemplate>
<asp:Label ID="lblsocial" runat="server" Text='<%#Eval("social")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Hindi">
<ItemTemplate>
<asp:Label ID="lblhindi" runat="server" Text='<%#Eval("Hindi")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>--%>
<asp:TemplateField HeaderText="Total Marks">
<ItemTemplate>
<asp:Label ID="lbltotalmarks" runat="server"
Text='<%#Eval("Total_Marks") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="UnitI">
<ItemTemplate>
<asp:Label ID="lblunit1" runat="server" Text=""></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Grade">
<ItemTemplate>
<asp:Label ID="lblgrade" runat="server" Text=""></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="UnitII">
<ItemTemplate>
<asp:Label ID="lblunit2" runat="server" Text=""></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Grade">
<ItemTemplate>
<asp:Label ID="lblgrade1" runat="server" Text=""></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
.cs code:-
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;
//l10.Text = ds.Tables[0].Columns[0].ToString();
//l10.Text = "460";
//l11.Text = "b";
}
}
public void calculate1()
{
foreach(GridViewRow x in GridView1.Rows)
{
Label l1 = (Label)x.FindControl("lblid");
Label l10 = (Label)x.FindControl("lblunit2");
Label l11 = (Label)x.FindControl("lblgrade1");
Label ltotal = (Label)x.FindControl("lbltotalmarks");
string s = "select Total_Marks from StudentMarks where ID=101";
SqlDataAdapter da = new SqlDataAdapter(s, con);
DataSet ds = new DataSet();
da.Fill(ds);
int p = (Convert.ToInt32(ltotal.Text) / 6);
if (p < 40)
{
l10.Text=ltotal.Text+"/600";
l11.Text="F";
}
else if (p > 40 && p < 50)
{
l10.Text = ltotal.Text + "/600";
l11.Text = "C";
}
else if (p > 51 && p < 60)
{
l10.Text = ltotal.Text + "/600";
l11.Text = "B";
}
else if (p > 61 && p < 70)
{
l10.Text = ltotal.Text + "/600";
l11.Text = "B+";
}
else if (p> 71 &&p < 80)
{
l10.Text = ltotal.Text + "/600";
l11.Text = "A-";
}
else if (p > 81 &&p < 90)
{
l10.Text = ltotal.Text + "/600";
l11.Text = "A";
}
else
{
l10.Text = ltotal.Text + "/600";
l11.Text = "A+";
}
}
}
Output:-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Gridview move.aspx.cs"
Inherits="Gridview_move" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
if (e.CommandName == "down")
{
i = Convert.ToInt32(e.CommandArgument);
r1 = GridView1.Rows[i];
r2 = GridView1.Rows[i + 1];
int phonenumber =
Convert.ToInt32(GridView1.DataKeys[r1.RowIndex].Value.ToString());
//int phonenumber =
Convert.ToInt32(GridView1.DataKeys[r1.RowIndex].Values["Phone"].ToString());
int value1 = Convert.ToInt32(r1.Cells[0].Text);
int value2 = Convert.ToInt32(r2.Cells[0].Text);
string s = "update customers3 set Phone=@p1 where Id=@p2;update customers3
set Phone=@p3 where Id=@p4 ";
cmd = new SqlCommand(s, con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@p1", phonenumber + 1);
cmd.Parameters.AddWithValue("@p2", value1);
cmd.Parameters.AddWithValue("@p3", phonenumber);
cmd.Parameters.AddWithValue("@p4", value2);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
get();
}
}
Ouput:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</HeaderTemplate>
<ItemTemplate>
<asp:DropDownList ID="ddlstatus" runat="server"
><asp:ListItem>Select</asp:ListItem></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Save" />
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
.cs code:-
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;
if (!IsPostBack)
{
get();
add();
}
}
public void get()
{
SqlDataAdapter da = new SqlDataAdapter("select * from customers",con);
DataTable ds = new DataTable();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
public void add()
{
GridViewRow r = GridView1.HeaderRow;
DropDownList d=(DropDownList)r.FindControl("ddlemployee");
d.Items.Insert(0, "select");
d.Items.Insert(1,"Activate");
d.Items.Insert(2, "DeActivate");
d.Items.Insert(3, "Prospect");
//s = d.SelectedItem.ToString();
//foreach (GridViewRow x in GridView1.Rows)
//{
// DropDownList d3 = (DropDownList)x.FindControl("ddlstatus");
// d3.Items.Add("select");
//}
}
public void select(object sender, EventArgs e)
{
GridViewRow r = GridView1.HeaderRow;
DropDownList d = (DropDownList)r.FindControl("ddlemployee");
string s = d.SelectedItem.ToString(); ;
foreach (GridViewRow x in GridView1.Rows)
{
DropDownList d2 = (DropDownList)x.FindControl("ddlstatus");
d2.Items.Clear();
d2.Items.Add(s);
}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow x in GridView1.Rows)
{
DropDownList d = (DropDownList)x.FindControl("ddlstatus");
Label l=(Label)x.FindControl("lblid");
//string s="update customers set status=@p1 where Id=@p2";
//cmd=new SqlCommand(s,con);
//cmd.CommandType = CommandType.Text;
//cmd.Parameters.AddWithValue("@p1",d.Text);
//cmd.Parameters.AddWithValue("@p2",l.Text);
//con.Open();
//cmd.ExecuteNonQuery();
//con.Close();
//lblMessage.Text = "Status Updated Successfully";
string s;
if (d.Text == "Activate")
{
s = "update customers set status='1' where Id=" + l.Text;
}
else if (d.Text == "DeActivate")
{
s = "update customers set status='2' where Id=" + l.Text;
}
else
{
s = "update customers set status='3' where Id=" + l.Text;
}
cmd=new SqlCommand(s,con);
cmd.CommandType=CommandType.Text;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
lblMessage.Text="Database Updated Successfully";
}
}
}
Output:-
Task on Gridviw with Redirection of Selectd row:-
03/11/2015
Target page:-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Save.aspx.cs" Inherits="Save" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
height: 201px;
width: 553px;
}
.auto-style2 {
width: 265px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
}
protected void btnsave_Click(object sender, EventArgs e)
{
string s="insert into emp values(@p1,@p2,@p3,@p4,@p5,@p5)";
cmd = new SqlCommand(s, con);
cmd.Parameters.AddWithValue("@p1",txtempid.Text);
cmd.Parameters.AddWithValue("@p2",txtename.Text);
cmd.Parameters.AddWithValue("@p3",txtdesignation.Text);
cmd.Parameters.AddWithValue("@p4",txtdoj.Text);
cmd.Parameters.AddWithValue("@p5",txtsalary.Text);
cmd.Parameters.AddWithValue("@p6",txtdeptno.Text);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
lblMessage.Text = i + "Row (s) Inserted";
}
protected void btnupdate_Click(object sender, EventArgs e)
{
txtempid.Text = Request.QueryString["id"];
txtename.Text = Request.QueryString["name"];
txtdesignation.Text = Request.QueryString["designation"];
txtdoj.Text = Request.QueryString["doj"];
txtsalary.Text = Request.QueryString["salary"];
txtdeptno.Text = Request.QueryString["deptno"];
}
}
Output:-
Source Page:-
.aspx code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Gridview.aspx.cs"
Inherits="Gridview" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
.cs code:-
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;
public partial class Gridview : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("server=.;user
id=sa;password=123456;database=employs");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
get();
}
}
public void get()
{
SqlDataAdapter da = new SqlDataAdapter("select * from emp",con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
Output:-
After Redirection:-