zoukankan      html  css  js  c++  java
  • 12.22 repeater 添加

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class Insert : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (Session["uid"] != null)
    {
    if (!IsPostBack)
    {

    InfoDataContext context = new InfoDataContext();

    DropDownList1.DataSource = context.Nation;
    DropDownList1.DataTextField = "Name";
    DropDownList1.DataValueField = "Code";

    DropDownList1.DataBind();
    }

    }
    else
    {
    Response.Redirect("denglu.aspx");

    }

    }


    protected void Button1_Click(object sender, EventArgs e)
    {
    InfoDataContext context = new InfoDataContext();
    string code = txtCode.Text;
    string name = txtName.Text;
    bool sex = rdnan.Checked;
    string nation = DropDownList1.SelectedValue;
    DateTime birthday = Convert.ToDateTime(txtBirthday.Text);


    //造对象
    Info data = new Info();
    data.Code = code;
    data.Name = name;
    data.Sex = sex;
    data.Nation = nation;
    data.Birthday = birthday;

    //提交数据改动
    context.Info.InsertOnSubmit(data);

    context.SubmitChanges();

    //清空数据
    Clear();
    }

    public void Clear()
    {

    txtCode.Text = "";
    txtName.Text = "";
    txtBirthday.Text = "";
    DropDownList1.SelectedIndex = 0;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
    Response.Redirect("Main.aspx");
    }
    }

  • 相关阅读:
    CSRF跨站请求伪造
    FineReport 导出汉字乱码
    Java 程序中中文没有乱码,存入数据库后中文乱码问题
    分析函数
    Redis的持久化与主从复制
    分布式Redis的使用
    redis的介绍和安装
    Solr后台管理及SolrJ的使用
    Solr总结
    bootstrap 点击回到顶部 超简单
  • 原文地址:https://www.cnblogs.com/cf924823/p/5065727.html
Copyright © 2011-2022 走看看