using System;
using System.Configuration;
using System.Data;
using 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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void clear()
{
txtroll.Text = "";
txtsearch.Text = "";
txtsearch1.Text = "";
}
protected void Button2_Click(object sender, EventArgs e)
{
linqtosqlDataContext ltx = new linqtosqlDataContext();
mydata1 lk = new mydata1();
lk.roll = txtroll.Text;
lk.name = txtsearch.Text.Trim();
lk.address = txtsearch1.Text.Trim();
// ltx.mydata1s.InsertOnSubmit(lk);
ltx.mydata1s.InsertOnSubmit (lk);
try
{
ltx.SubmitChanges();
Response.Write("<p style='color:Green;'>Data Inserted!</p>");
//Response.Write("Data Inserted");
clear();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
//ctx.Employees.InsertOnSubmit(myemp);
}
protected void Button1_Click(object sender, EventArgs e)
{
//mydata1 lk = new mydata1();
//lk.roll = Convert.ToInt32(txtroll.Text);
//bussinnesslayer bll = new bussinnesslayer();
//DataSet ds = new DataSet();
//var a= bll.Show_Data( );
//GridView1.DataSource = a;
//GridView1.DataBind();
//Response.Write("Data show");
//Response.Write("<p style='color:Green;'>Information Successfully saved!</p>");
//-----------------------------------on page---------------------------------------------------------------------------------------------
//linqtosqlDataContext ctx = new linqtosqlDataContext();
//var mydata = from myvalue in ctx.mydata1s
// where myvalue.roll == Convert.ToInt32(txtroll.Text)
// select myvalue;
////foreach (var data in emps)
////{
//// Label1.Text = data.name;
//// Label2.Text = data.address;
////}
//GridView1.DataSource = mydata;
//GridView1.DataBind();
//Response.Write("find");
//clear();
}
protected void btndel_Click(object sender, EventArgs e)
{
linqtosqlDataContext ltd = new linqtosqlDataContext();
var deldata = ltd.mydata1s.Single(roll => roll.roll.Equals(Convert.ToInt32(txtroll.Text)));
ltd.mydata1s.DeleteOnSubmit(deldata);
try
{
ltd.SubmitChanges();
Response.Write("<p style='color:red;'>Data Deleted!</p>");
//Response.Write("Data Deleted");
clear();
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}
protected void btnupdate_Click(object sender, EventArgs e)
{
linqtosqlDataContext ltd = new linqtosqlDataContext();
//mydata1 myd=new mydata1();
//var updata = ltd.mydata1s.Single(udate=>udate.roll.Equals(Convert.ToInt32(txtroll.Text)));
//myd.name = txtsearch.Text;
//myd.addres = txtsearch1.Text;
//ltd.SubmitChanges(myd);
//Response.Write("Data Upadated");
var updata = ltd.mydata1s.First(roll => roll.roll.Equals(Convert.ToInt32(txtroll.Text)));
updata.name = txtsearch.Text;
updata.address = txtsearch1.Text;
ltd.SubmitChanges();
Response.Write("<p style='color:Green;'>Data Updated!</p>");
}
protected void Button3_Click(object sender, EventArgs e)
{
}
protected void Button3_Click1(object sender, EventArgs e)
{
//mydata1 lk = new mydata1();
//lk.roll = txtroll.Text;
//bussinnesslayer bll = new bussinnesslayer();
//DataSet ds = new DataSet();
//var a = bll.Show_Data();
//GridView1.DataSource = a;
//GridView1.DataBind();
//Response.Write("Data show");
}
}
using System.Configuration;
using System.Data;
using 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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void clear()
{
txtroll.Text = "";
txtsearch.Text = "";
txtsearch1.Text = "";
}
protected void Button2_Click(object sender, EventArgs e)
{
linqtosqlDataContext ltx = new linqtosqlDataContext();
mydata1 lk = new mydata1();
lk.roll = txtroll.Text;
lk.name = txtsearch.Text.Trim();
lk.address = txtsearch1.Text.Trim();
// ltx.mydata1s.InsertOnSubmit(lk);
ltx.mydata1s.InsertOnSubmit (lk);
try
{
ltx.SubmitChanges();
Response.Write("<p style='color:Green;'>Data Inserted!</p>");
//Response.Write("Data Inserted");
clear();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
//ctx.Employees.InsertOnSubmit(myemp);
}
protected void Button1_Click(object sender, EventArgs e)
{
//mydata1 lk = new mydata1();
//lk.roll = Convert.ToInt32(txtroll.Text);
//bussinnesslayer bll = new bussinnesslayer();
//DataSet ds = new DataSet();
//var a= bll.Show_Data( );
//GridView1.DataSource = a;
//GridView1.DataBind();
//Response.Write("Data show");
//Response.Write("<p style='color:Green;'>Information Successfully saved!</p>");
//-----------------------------------on page---------------------------------------------------------------------------------------------
//linqtosqlDataContext ctx = new linqtosqlDataContext();
//var mydata = from myvalue in ctx.mydata1s
// where myvalue.roll == Convert.ToInt32(txtroll.Text)
// select myvalue;
////foreach (var data in emps)
////{
//// Label1.Text = data.name;
//// Label2.Text = data.address;
////}
//GridView1.DataSource = mydata;
//GridView1.DataBind();
//Response.Write("find");
//clear();
}
protected void btndel_Click(object sender, EventArgs e)
{
linqtosqlDataContext ltd = new linqtosqlDataContext();
var deldata = ltd.mydata1s.Single(roll => roll.roll.Equals(Convert.ToInt32(txtroll.Text)));
ltd.mydata1s.DeleteOnSubmit(deldata);
try
{
ltd.SubmitChanges();
Response.Write("<p style='color:red;'>Data Deleted!</p>");
//Response.Write("Data Deleted");
clear();
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}
protected void btnupdate_Click(object sender, EventArgs e)
{
linqtosqlDataContext ltd = new linqtosqlDataContext();
//mydata1 myd=new mydata1();
//var updata = ltd.mydata1s.Single(udate=>udate.roll.Equals(Convert.ToInt32(txtroll.Text)));
//myd.name = txtsearch.Text;
//myd.addres = txtsearch1.Text;
//ltd.SubmitChanges(myd);
//Response.Write("Data Upadated");
var updata = ltd.mydata1s.First(roll => roll.roll.Equals(Convert.ToInt32(txtroll.Text)));
updata.name = txtsearch.Text;
updata.address = txtsearch1.Text;
ltd.SubmitChanges();
Response.Write("<p style='color:Green;'>Data Updated!</p>");
}
protected void Button3_Click(object sender, EventArgs e)
{
}
protected void Button3_Click1(object sender, EventArgs e)
{
//mydata1 lk = new mydata1();
//lk.roll = txtroll.Text;
//bussinnesslayer bll = new bussinnesslayer();
//DataSet ds = new DataSet();
//var a = bll.Show_Data();
//GridView1.DataSource = a;
//GridView1.DataBind();
//Response.Write("Data show");
}
}
No comments:
Post a Comment