zoukankan      html  css  js  c++  java
  • 20151221:Web复习:添加

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Insert.aspx.cs" Inherits="Insert" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
         <style type="text/css">
                    * {
                        margin: 0px auto;
                        padding: 0px;
                    }
         </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="aa" style="400px">
            <h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h1>
            <h1>&nbsp;</h1>
            <h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;添加数据</h1>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>
                &nbsp;</p>
            <p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Label ID="Label1" runat="server" Text="代号:"></asp:Label>
                <asp:TextBox ID="txtCode" runat="server"></asp:TextBox>
                &nbsp;</p>
            <p>
                &nbsp;</p>
            <p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Label ID="Label2" runat="server" Text="姓名:"></asp:Label>
                <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
    &nbsp;
            </p>
            <p>
                &nbsp;</p>
            <p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Label ID="Label3" runat="server" Text="性别:"></asp:Label>
                <asp:RadioButton ID="rdnan" runat="server" Text="男" Checked="True" GroupName="sex" />
    &nbsp;&nbsp;
                <asp:RadioButton ID="rdnv" runat="server" Text="女" GroupName="sex" />
            </p>
            <p>
                &nbsp;</p>
            <p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Label ID="Label4" runat="server" Text="民族:"></asp:Label>
                <asp:DropDownList ID="drNation" runat="server">
                </asp:DropDownList>
            </p>
            <p>
                &nbsp;</p>
            <p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Label ID="Label5" runat="server" Text="生日:"></asp:Label>
                <asp:TextBox ID="txtBirthday" runat="server"></asp:TextBox>
                &nbsp;</p>
            <p>
                &nbsp;</p>
            <p>
                &nbsp;</p>
            <p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="确定" />
    &nbsp;&nbsp;&nbsp;
                <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="返回" />
                &nbsp;</p>
            <p>&nbsp;</p>
    
        </div>
        </form>
    </body>
    </html>
    后台C#代码:

    public
    partial class Insert : 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(); } } else { Response.Redirect("Denglu.aspx"); } } protected void Button1_Click(object sender, EventArgs e) { Info data = new Info();//造对象 //赋值 data.Code = txtCode.Text; data.Name = txtName.Text; data.Sex = rdnan.Checked; data.Nation = drNation.SelectedValue; data.Birthday = Convert.ToDateTime(txtBirthday.Text); //添加到数据库 context.Info.InsertOnSubmit(data); context.SubmitChanges();//提交 Clear(); } public void Clear() { //清空 txtCode.Text = ""; txtName.Text = ""; rdnan.Checked= true; drNation.SelectedIndex = 0; txtBirthday.Text = ""; } protected void Button2_Click(object sender, EventArgs e) { Response.Redirect("Main.aspx"); } }

  • 相关阅读:
    pandas取值
    pandas 基本操作
    Pandas三个数据结构
    pandas.Series
    scipy线性模块liner(linalg)
    numpy meshgrid函数
    scipy插值interpolation
    scipy优化器optimizer
    scipy积分 integral
    8086汇编 Loop 指令
  • 原文地址:https://www.cnblogs.com/mn-b/p/5074536.html
Copyright © 2011-2022 走看看