20151217:Web之Repeater使用:修改
修改界面后台C#代码:
public partial class Update : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string ids = Request["ids"].ToString(); //显示原来的数据 TestDataContext context = new TestDataContext(); Fruit data = context.Fruit.Where(p => p.Ids == ids).First();//查询 txtCode.Text = data.Ids;//传值 txtName.Text = data.Name; txtPrice.Text = data.Price.ToString(); txtSource.Text = data.Source; txtNumbers.Text = data.Numbers.ToString(); } } protected void Button1_Click(object sender, EventArgs e) { TestDataContext context = new TestDataContext(); Fruit data = context.Fruit.Where(p => p.Ids == txtCode.Text).First(); data.Name = txtName.Text; data.Price = Convert.ToDecimal(txtPrice.Text); data.Source = txtSource.Text; data.Numbers = Convert.ToInt32(txtNumbers.Text); context.SubmitChanges(); } protected void Button2_Click(object sender, EventArgs e) { Response.Redirect("1217.aspx");//跳转页面 } }