• 20151221:Web复习:修改


    后台:

    public partial class Update : System.Web.UI.Page
    {
        private TextDataContext context = new TextDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["uid"] != null)
            {
                if (!IsPostBack)
                {
                    //给民族下拉列表绑定数据
                    drNation.DataSource = context.Nation;
                    drNation.DataTextField = "Name";
                    drNation.DataValueField = "Code";
                    drNation.DataBind();
                    //取主键值
                    string code = Request["code"].ToString();
                    //查数据库
                    Info data = context.Info.Where(p => p.Code == code).First();
                    //填上数据
                    txtCode.Text = data.Code;
                    txtName.Text = data.Name;
                    txtBirthday.Text = data.Birthday.Value.ToString("yyyy年MM月dd日");
                    if (data.Sex == true)
                    {
                        rdnan.Checked = true;
                    }
                    else
                    {
                        rdnv.Checked = true;
                    }
                    foreach( ListItem item in drNation.Items )
                    {
                        if(item.Value == data.Nation)
                        {
                            item.Selected = true;
                        }
                    }
                }
            }
            else
            {
                Response.Redirect("Denglu.aspx");
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //查到这条数据
            Info data = context.Info.Where(p => p.Code == txtCode.Text).First();
            //修改内容
            data.Name = txtName.Text;
            data.Sex = rdnan.Checked;
            data.Nation = drNation.SelectedValue;
            data.Birthday = Convert.ToDateTime(txtBirthday.Text);
            //提交
            context.SubmitChanges();
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("Main.aspx");
        }

  • 相关阅读:
    Linux内核源码分析方法
    OVS处理upcall流程分析
    Linux内核源码目录结构分析
    理解OpenStack中的OpenvSwitch的几个要点
    OVS源码connmgr_run分析
    ovs-appctl 命令合集
    云计算底层技术-使用openvswitch
    OVS架构
    Open vSwitch Datapath浅析
    Openvswitch原理与代码分析(4):网络包的处理过程
  • 原文地址:https://www.cnblogs.com/mn-b/p/5074541.html
Copyright © 2020-2023  润新知