码迷,mamicode.com
首页 > Web开发 > 详细

20151217:Web之Repeater使用:修改

时间:2015-12-24 23:42:47      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:

修改界面后台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");//跳转页面
    }
}

技术分享

20151217:Web之Repeater使用:修改

标签:

原文地址:http://www.cnblogs.com/mn-b/p/5074488.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!