Webformによるテーブルの削除
9418 ワード
添削改ざんの方法コード
メインインタフェースのコード
コードの変更
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class xiugai : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string id = Request["code"].ToString();
Car data = new CarBf().Select(id);
Session["car"] = data;
TextBox1.Text = data.Code;
TextBox2.Text = data.Name;
TextBox3.Text = data.Price.ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
// session , new
Car data = (Car)Session["car"];
data.Code = TextBox1.Text;
data.Name = TextBox2.Text;
data.Price = Convert.ToDecimal(TextBox3.Text);
new CarBf().Update(data);
Response.Redirect("Car.aspx");
}
}
メインインタフェースのコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Car1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Car> list = new CarBf().Select();
string s = " <table width=' 100%' border='1'><tr class='tr1'><td> </td><td> </td><td> </td><td> </td></tr>";
foreach (Car data in list)
{
s+=" <tr class='tr2'><td>"+data.Code+"</td><td><a href='xianshi.aspx?code="+data.Code+"'>"+data.Name+"</a></td><td>"+data.Price+ "</td><td><a href='Delete.aspx?code=" + data.Code + "'> </a><a href='Update.aspx?code=" + data.Code + "'> </a></td></tr>";
}
s+="</table><a href='Insert.aspx'> <a/>";
Literal1.Text=s;
}
}
コードの変更
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class xiugai : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string id = Request["code"].ToString();
Car data = new CarBf().Select(id);
Session["car"] = data;
TextBox1.Text = data.Code;
TextBox2.Text = data.Name;
TextBox3.Text = data.Price.ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
// session , new
Car data =new Car();
data.Code = TextBox1.Text;
TextBox1.Enabled = false;
data.Name = TextBox2.Text;
data.Price = Convert.ToDecimal(TextBox3.Text);
new CarBf().Update(data);
Response.Redirect("Car.aspx");
}
}