using
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Web;
System.Web.UI;
System.Web.UI.WebControls;
</div>
</form>
</body>
</html>
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Web;
System.Web.UI;
System.Web.UI.WebControls;
CSS
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CSS.aspx.cs"
Inherits="CSS" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<style type="text/css">
div
{
padding:10px;
}
.labelstyle
{
color:Red;
background-color:Yellow;
border:solid 2px red;
}
</style>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<p>
<asp:Label ID="Label1" runat="server" BackColor="#FFFF66"
BorderColor="#FF3300"
BorderStyle="Solid" BorderWidth="2px" ForeColor="#FF3300" Text="First
label"></asp:Label>
</p>
<p>
<asp:Label ID="Label2" runat="server" CssClass="labelstyle" Text="Second
label"></asp:Label>
<br />
</p>
<div>
</div>
</form>
</body>
</html>
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Web;
System.Web.UI;
System.Web.UI.WebControls;
Calculator
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)
{
if ((TextBox1.Text == "+") || (TextBox1.Text == "-") || (TextBox1.Text =="*") ||
(TextBox1.Text == "/"))
{
TextBox1.Text = "";
TextBox1.Text = TextBox1.Text + Button2.Text;
}
else
{
TextBox1.Text = TextBox1.Text + Button2.Text;
}
}
protected void Button3_Click(object sender, EventArgs e)
{
if ((TextBox1.Text == "+") || (TextBox1.Text == "-") || (TextBox1.Text =="*") ||
(TextBox1.Text == "/"))
{
TextBox1.Text = "";
TextBox1.Text = TextBox1.Text + Button3.Text;
}
else
{
TextBox1.Text = TextBox1.Text + Button3.Text;
}
}
}
else
{
TextBox1.Text = TextBox1.Text + Button6.Text;
}
}
protected void Button7_Click(object sender, EventArgs e)
{
if ((TextBox1.Text == "+") || (TextBox1.Text == "-") || (TextBox1.Text =="*") ||
(TextBox1.Text == "/"))
{
TextBox1.Text = "";
TextBox1.Text = TextBox1.Text + Button7.Text;
}
else
{
TextBox1.Text = TextBox1.Text + Button7.Text;
}
}
protected void Button8_Click(object sender, EventArgs e)
{
a = Convert.ToInt32(TextBox1.Text);
TextBox1.Text = "";
b = '-';
TextBox1.Text += b;
}
protected void Button9_Click(object sender, EventArgs e)
{
if ((TextBox1.Text == "+") || (TextBox1.Text == "-") || (TextBox1.Text =="*") ||
(TextBox1.Text == "/"))
{
TextBox1.Text = "";
TextBox1.Text = TextBox1.Text + Button9.Text;
}
else
{
TextBox1.Text = TextBox1.Text + Button9.Text;
}
}
protected void Button10_Click(object sender, EventArgs e)
{
if ((TextBox1.Text == "+") || (TextBox1.Text == "-") || (TextBox1.Text =="*") ||
(TextBox1.Text == "/"))
{
TextBox1.Text = "";
TextBox1.Text = TextBox1.Text + Button10.Text;
}
else
{
TextBox1.Text = TextBox1.Text + Button10.Text;
}
}
protected void Button11_Click(object sender, EventArgs e)
{
{
TextBox1.Text = TextBox1.Text + Button13.Text;
}
}
protected void Button14_Click(object sender, EventArgs e)
{
TextBox1.Text ="";
}
protected void Button15_Click(object sender, EventArgs e)
{
a = Convert.ToInt32(TextBox1.Text);
TextBox1.Text = "";
b = '/';
TextBox1.Text += b;
}
protected void Button16_Click(object sender, EventArgs e)
{
c = Convert.ToInt32(TextBox1.Text);
TextBox1.Text = "";
if(b=='/')
{
d = a / c;
TextBox1.Text += d;
a = d;
}
else if (b == '+')
{
d = a + c;
TextBox1.Text += d;
a = d;
}
else if (b == '-')
{
d = a - c;
TextBox1.Text += d;
a = d;
}
else
{
d = a * c;
TextBox1.Text += d;
a = d;
}
}
}
using
using
using
using
System;
System.Configuration;
System.Data;
System.Linq;
using
using
using
using
using
using
using
using
System.Web;
System.Web.Security;
System.Web.UI;
System.Web.UI.HtmlControls;
System.Web.UI.WebControls;
System.Web.UI.WebControls.WebParts;
System.Xml.Linq;
System.Data.SqlClient;
Repeater
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 paging : System.Web.UI.Page
}
public void pageno(int totItems)
{
// Calculate total numbers of pages
int pgCount = totItems / 5 + totItems % 5;
Datalist
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:DataList ID="DataList1" runat="server" DataKeyField="Cid"
oncancelcommand="DataList1_CancelCommand"
oneditcommand="DataList1_EditCommand"
onupdatecommand="DataList1_UpdateCommand"
onselectedindexchanged="DataList1_SelectedIndexChanged">
<ItemTemplate>
<b>Course Id:</b> <%# Eval("Cid") %><br />
<b>Course Name:</b> <%# Eval("Cname") %><br />
<b>Course Teacher:</b> <%# Eval("Teacher") %><br />
<b>Course Duration:</b> <%# Eval("Duration") %> <br />
<asp:LinkButton Id="lk" Text="Edit" CommandName ="edit" runat ="server"
></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<b>Course id:</b><asp:TextBox ID="t1" Text ='<%# bind("Cid") %>' runat
="server" ></asp:TextBox>
<b>Course Name:</b><asp:TextBox ID="t2" Text ='<%# bind("Cname") %>'
runat ="server" ></asp:TextBox>
<b>Course Teacherid:</b><asp:TextBox ID="t3" Text ='<%# bind("Teacher")
%>' runat ="server" ></asp:TextBox>
<b>Course Duration:</b><asp:TextBox ID="t4" Text ='<%# bind("Duration")
%>' runat ="server" ></asp:TextBox>
<asp:LinkButton ID="lk1" Text ="Update" CommandName ="update" runat
="server"></asp:LinkButton><br />
<asp:LinkButton ID="lk2" Text ="Cancel" CommandName ="cancel" runat
="server"></asp:LinkButton>
</EditItemTemplate>
</asp:DataList>
</form>
</body>
</html>
using
using
using
using
System;
System.Configuration;
System.Data;
System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
listbind();
}
}
private void listbind()
{
SqlDataAdapter adp=new SqlDataAdapter("select * from
Cours",ConfigurationManager.ConnectionStrings["cn"].ConnectionString);
DataSet ds=new DataSet();
adp.Fill(ds);
DataList1.DataSource =ds;
DataList1.DataBind();
}
e)
Int32 Cid;
Cid = Convert.ToInt32(DataList1.DataKeys[e.Item.ItemIndex]);
SqlConnection con = new SqlConnection();
con.ConnectionString =
ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "update Cours set
Cname=@Cname,Teacher=@Teacher,Duration=@Duration where Cid=@Cid";
cmd.Connection = con;
cmd.Parameters.Add("@Cid", SqlDbType.Int).Value = Cid;
cmd.Parameters.Add("@Cname", SqlDbType.VarChar).Value = ((TextBox)
(e.Item.FindControl("t2"))).Text ;
cmd.Parameters.Add("@Teacher", SqlDbType.VarChar ).Value = ((TextBox)
(e.Item.FindControl("t3"))).Text ;
cmd.Parameters.Add("@Duration", SqlDbType.Int).Value = ((TextBox)
(e.Item.FindControl("t4"))).Text;
cmd.ExecuteNonQuery();
DataList1.EditItemIndex = -1;
listbind();
}
protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
DataList1.EditItemIndex = e.Item.ItemIndex;
listbind();
}
protected void DataList1_CancelCommand(object source, DataListCommandEventArgs
e)
{
DataList1.EditItemIndex = -1;
listbind();
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
Gidview
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True" AutoGenerateSelectButton="True"
DataKeyNames="Cid" DataSourceID="SqlDataSource1"
onrowupdating="GridView1_RowUpdating"
onselectedindexchanged="GridView1_SelectedIndexChanged"
AutoGenerateColumns="False" >
<Columns>
<asp:BoundField DataField="Cid" HeaderText="Cid" ReadOnly="True"
SortExpression="Cid" />
<asp:BoundField DataField="Cname" HeaderText="Cname"
SortExpression="Cname" />
<asp:BoundField DataField="Teacher" HeaderText="Teacher"
SortExpression="Teacher" />
<asp:BoundField DataField="Duration" HeaderText="Duration"
SortExpression="Duration" />
</Columns>
</asp:GridView>
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Configuration;
System.Data;
System.Linq;
System.Web;
System.Web.Security;
System.Web.UI;
System.Web.UI.HtmlControls;
System.Web.UI.WebControls;
System.Web.UI.WebControls.WebParts;
System.Xml.Linq;
System.Data.SqlClient;
SqlDataSource1.Update();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text = GridView1.SelectedRow.Cells[1].Text;
TextBox2.Text = GridView1.SelectedRow.Cells[2].Text;
TextBox3.Text = GridView1.SelectedRow.Cells[3].Text;
}
}
DetailView
font-family: verdana,arial,sans-serif;
font-size: 11px;
}
.textbox
{
border-width: 1px;
padding: 1px;
border-style: solid;
border-color: #999999;
font-family: verdana,arial,sans-serif;
font-size: 11px;
width: 100px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DetailsView ID="DetailsViewExample" AllowPaging="true"
AutoGenerateRows="false"
runat="server" Height="50px" CssClass="DetailsViewClass" CellPadding="4"
OnPageIndexChanging="DetailsViewExample_PageIndexChanging"
OnItemCommand="DetailsViewExample_ItemCommand1"
OnItemUpdating="DetailsViewExample_ItemUpdating"
OnModeChanging="DetailsViewExample_ModeChanging"
OnItemInserting="DetailsViewExample_ItemInserting"
Width="270px" OnItemDeleting="DetailsViewExample_ItemDeleting">
<Fields>
<asp:TemplateField HeaderText="Course Id">
<ItemTemplate>
<asp:Label ID="lblCid" Text='<%# Eval("Cid") %>' Visible="true"
runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtCid" Text='<%# Eval("Cid") %>' runat="server"
CssClass="textbox"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Course Name">
<ItemTemplate>
<asp:Label ID="lblCName" Text='<%# Eval("CName") %>'
runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtCName" Text='<%# Eval("CName") %>'
runat="server" CssClass="textbox"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Teacher">
<ItemTemplate>
<asp:Label ID="lblTeacher" Text='<%# Eval("Teacher") %>'
runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
using
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Configuration;
System.Data;
System.Linq;
System.Web;
System.Web.Security;
System.Web.UI;
System.Web.UI.HtmlControls;
System.Web.UI.WebControls;
System.Web.UI.WebControls.WebParts;
System.Xml.Linq;
System.Data.Sql;
System.Data.SqlClient;
DetailsViewExample.DataBind();
}
catch (Exception ex) { throw ex; }
}
private DataSet GetDataSet(string Query)
{
DataSet Ds = new DataSet();
try
{
SqlConnection Con = new SqlConnection();
Con.ConnectionString =
ConfigurationManager.ConnectionStrings["StudentConnectionString"].ConnectionString;
Con.Open();
SqlDataAdapter Da = new SqlDataAdapter(Query, Con);
Da.Fill(Ds);
}
catch (Exception) { }
return Ds;
}
private void ExecuteQuery(string Query)
{
try
{
SqlConnection Con = new SqlConnection();
Con.ConnectionString =
ConfigurationManager.ConnectionStrings["StudentConnectionString"].ConnectionString;
Con.Open();
SqlCommand cmd = new SqlCommand(Query, Con);
cmd.ExecuteNonQuery();
Con.Close();
cmd.Dispose();
}
catch (Exception) { }
}
protected void DetailsViewExample_PageIndexChanging(object sender,
DetailsViewPageEventArgs e)
{
DetailsViewExample.PageIndex = e.NewPageIndex;
bindDetailtView();
}
protected void DetailsViewExample_ItemCommand1(object sender,
DetailsViewCommandEventArgs e)
{
switch (e.CommandName.ToString())
{
case "Edit":
DetailsViewExample.ChangeMode(DetailsViewMode.Edit);
bindDetailtView();
break;
case "Cancel":
DetailsViewExample.ChangeMode(DetailsViewMode.ReadOnly);
bindDetailtView();
break;
case "New":
DetailsViewExample.ChangeMode(DetailsViewMode.Insert);
bindDetailtView();
break;
}
}
protected void DetailsViewExample_ModeChanging(object sender,
DetailsViewModeEventArgs e)
{
}
protected void DetailsViewExample_ItemUpdating(object sender,
DetailsViewUpdateEventArgs e)
{
TextBox txtCid = (TextBox)DetailsViewExample.FindControl("txtCid") ;
TextBox txtCname = (TextBox)DetailsViewExample.FindControl("txtCname");
TextBox txtTeacher = (TextBox)DetailsViewExample.FindControl("txtTeacher");
TextBox txtDuration = (TextBox)DetailsViewExample.FindControl("txtDuration");
string Query = "Update Cours Set Cname ='" + txtCname.Text + "' ,Teacher ='" +
txtTeacher.Text + "',Duration=" + Convert.ToInt32(txtDuration.Text) +" where Cid=" +
Convert.ToInt32( txtCid.Text) ;
ExecuteQuery(Query);
DetailsViewExample.ChangeMode(DetailsViewMode.ReadOnly);
bindDetailtView();
}
protected void DetailsViewExample_ItemInserting(object sender,
DetailsViewInsertEventArgs e)
{
TextBox txtCid = (TextBox)DetailsViewExample.FindControl("txtCid");
TextBox txtCname = (TextBox)DetailsViewExample.FindControl("txtCname");
TextBox txtTeacher = (TextBox)DetailsViewExample.FindControl("txtTeacher");
TextBox txtDuration = (TextBox)DetailsViewExample.FindControl("txtDuration");
string Query = "Insert into Cours ([Cid] ,[Cname] ,[Teacher] ,[Duration]) values
(" + Convert.ToInt32(txtCid.Text) + " ,'" + txtCname.Text + "' ,'" + txtTeacher.Text + "'," +
Convert.ToInt32(txtDuration.Text) + ")" ;
ExecuteQuery(Query);
DetailsViewExample.ChangeMode(DetailsViewMode.ReadOnly);
bindDetailtView();
}
protected void DetailsViewExample_ItemDeleting(object sender,
DetailsViewDeleteEventArgs e)
{
Label lblCid = (Label)DetailsViewExample.FindControl("lblCid");
string Query = "Delete from Cours where Cid =" + lblCid.Text;
ExecuteQuery(Query);
bindDetailtView();
}
}
FormView
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:FormView ID="FormView1" runat="server" AllowPaging="True">
<EditItemTemplate>
<asp:Label ID="lblcid" runat="server" Text="Course Id"></asp:Label>
&nbs
p;
<asp:TextBox ID="txtCid" runat="server" Text='<%# Eval("Cid")
%>'></asp:TextBox>
<br />
<br />
<asp:Label ID="lblCname" runat="server" Text="Course Name"></asp:Label>
&nbs
p;
<asp:TextBox ID="txtCname" runat="server" Text='<%# Eval("Cname")
%>'></asp:TextBox>
<br />
<br />
<asp:Label ID="lblteach" runat="server" Text="Teacher"></asp:Label>
&nbs
p;
<asp:TextBox ID="txtteach" runat="server" Text='<%# Eval("Teacher")
%>'></asp:TextBox>
<br />
<br />
<asp:Label ID="lblDuration" runat="server" Text="Duration"></asp:Label>
&nbs
p;
<asp:TextBox ID="txtDuration" runat="server" Text='<%# Eval("Duration")
%>'></asp:TextBox>
<br />
<br />
<br />
<asp:Button ID="btnupdate" runat="server" Text="Update" />
&nbs
p;
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
<br />
</EditItemTemplate>
<InsertItemTemplate>
<asp:Label ID="lblcid" runat="server" Text="Course Id"></asp:Label>
&nbs
p;
<asp:TextBox ID="txtCid" runat="server" Text='<%# Eval("Cid")
%>'></asp:TextBox>
<br />
<br />
<asp:Label ID="lblCname" runat="server" Text="Course Name"></asp:Label>
<asp:TextBox ID="txtCname" runat="server" Text='<%# Eval("Cname")
%>'></asp:TextBox>
<br />
<br />
<asp:Label ID="lblteach" runat="server" Text="Teacher"></asp:Label>
&nbs
p;
<asp:TextBox ID="txtteach" runat="server" Text='<%# Eval("Teacher")
%>'></asp:TextBox>
<br />
<br />
<asp:Label ID="lblDuration" runat="server" Text="Duration"></asp:Label>
&nbs
p;
<asp:TextBox ID="txtDuration" runat="server" Text='<%# Eval("Duration")
%>'></asp:TextBox>
<br />
<br />
<br />
<asp:Button ID="btnSave" runat="server" Text="Save" />
&nbs
p;
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
<br />
<br />
<br />
<br />
<br />
<br />
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="lblcid" runat="server" Text="Course Id"></asp:Label>
&nbs
p;
<asp:TextBox ID="txtCid" runat="server" Text='<%# Eval("Cid")
%>'></asp:TextBox>
<br />
<br />
<asp:Label ID="lblCname" runat="server" Text="Course Name"></asp:Label>
<asp:TextBox ID="txtCname" runat="server" Text='<%# Eval("CName")
%>'></asp:TextBox>
<br />
<br />
<asp:Label ID="lblteach" runat="server" Text="Teacher"></asp:Label>
&nbs
p;
using
using
using
using
using
using
using
using
using
using
using
System;
System.Configuration;
System.Data;
System.Linq;
System.Web;
System.Web.Security;
System.Web.UI;
System.Web.UI.HtmlControls;
System.Web.UI.WebControls;
System.Web.UI.WebControls.WebParts;
System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindDetailtView();
}
}
private void bindDetailtView()
{
try
{
DataSet Ds = GetDataSet("Select * from Cours");
FormView1.DataSource = Ds;
FormView1.DataBind();
}
}
catch (Exception) { }
return Ds;
Linq
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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">
</asp:GridView>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
<br />
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />
&nbs
p;
&nbs
p;
</form>
</body>
</html>
using
using
using
using
using
using
using
using
using
using
using
System;
System.Configuration;
System.Data;
System.Linq;
System.Web;
System.Web.Security;
System.Web.UI;
System.Web.UI.HtmlControls;
System.Web.UI.WebControls;
System.Web.UI.WebControls.WebParts;
System.Xml.Linq;
if (coudel.Count() > 0)
{
db.Cours.DeleteOnSubmit(coudel.First());
db.SubmitChanges();
}
Label1.Text = "Deleted";
}
protected void btnupdate_Click(object sender, EventArgs e)
{
CoursDataClassesDataContext db = new CoursDataClassesDataContext();
var couupdt = from p in db.Cours where p.Cid == Convert.ToInt32(TextBox1.Text)
select p;
foreach (var c in couupdt)
{
c.CName = TextBox2.Text;
c.Duration = Convert.ToInt32(TextBox4.Text);
c.Teacher = TextBox3.Text;
}
db.SubmitChanges();
Label1.Text = "Updated";
}
}
Linqdatasource Control
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Linqdatasource.aspx.cs"
Inherits="Linqdatasource" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="StudentClassesDataContext" EnableDelete="True"
EnableInsert="True" EnableUpdate="True" EntityTypeName=""
TableName="Cours">
</asp:LinqDataSource>
</div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Cid"
DataSourceID="LinqDataSource1">
<Columns>
<asp:BoundField DataField="Cid" HeaderText="Cid" ReadOnly="True"
SortExpression="Cid" />
<asp:BoundField DataField="Cname" HeaderText="Cname"
SortExpression="Cname" />
<asp:BoundField DataField="Teacher" HeaderText="Teacher"
SortExpression="Teacher" />
<asp:BoundField DataField="Duration" HeaderText="Duration"
SortExpression="Duration" />
<asp:BoundField DataField="sid" HeaderText="sid" SortExpression="sid" />
</Columns>
</asp:GridView>
</form>
</body>
</html>
Procedure:
ALTER PROCEDURE logincheck
(
@u varchar(50),
@p varchar(50)
)
AS
declare @ap varchar(50)
select @ap=password from tbuser where username=@u
if @ap is null
return -1
else
if @ap=@p
return 1
else return -2
RETURN
Coding file:
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Web;
System.Web.UI;
using
using
using
using
System.Web.UI.WebControls;
System.Data;
System.Data.SqlClient;
System.Configuration;
design page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
LOGIN:-<br />
<br />
USERNAME:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
PASSWORD:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</div>
</form>
</body>
</html>