下部分网格显示录入的记录 (数据保存在DataTable中)?????
设计一个页面上部分显示数据录入表单
下部分网格显示录入的记录 (数据保存在DataTable中)
字段:
学号(* 纯数字,视为ID,不可为空)
姓名(* 不可为空,最多4字)
出生日期
座机
手机(* 手机座机必填一个)
地址
邮编(* 需要验证格式)
下方不使用DataGrid显示DataTable数据,自己构建table
功能
网格显示数据出生日期字段要求格式为 2008-05-13
有全选 取消全选 下方按钮实现删除
每行有删除链接 删除一行
-----------------------
说明1。不能用datalist datagrid显示数据
2.不能用SQL作数据库
3.用datatable 添加字段并显示数据
--------------------编程问答-------------------- public partial class Default : System.Web.UI.Page
{
public static DataTable dt = new DataTable();
public static DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
{
DataTable DT = new DataTable();
method1();
add(100, "Join", Convert.ToDateTime("1980-10-12"), "68574105", "13718465201", "Beijing", "100000");
add(101, "Jo", Convert.ToDateTime("1980-10-12"), "68574105", "13718465201", "Beijing", "100000");
add(102, "Joi", Convert.ToDateTime("1980-10-12"), "68574105", "13718465201", "Beijing", "100000");
ds.Tables.Add(dt);
foreach (DataRow dr in dt.Rows)
{
Console.WriteLine(dr["ID"].ToString() + " " + dr["Name"].ToString() + " " + dr["birthday"].ToString() + " " +
dr["phone"].ToString() + " " + dr["mobile"].ToString() + " " + dr["address"].ToString() + " " + dr["code"].ToString());
}
try
{
foreach (DataTable dt2 in ds.Tables)
foreach (DataRow dr in dt2.Rows)
Console.WriteLine(dr["ID"].ToString() + " " + dr["Name"].ToString() + " " + dr["birthday"].ToString() + " " +
dr["phone"].ToString() + " " + dr["mobile"].ToString() + " " + dr["address"].ToString() + " " + dr["code"].ToString());
}
catch (Exception ex)
{
Console.WriteLine("error!" + ex.ToString());
}
}
}
}
public static void method1()
{
dt = new DataTable("Person");
ds = new DataSet();
dt.Columns.Add(new DataColumn("ID", typeof(Int32)));
dt.Columns.Add(new DataColumn("Name", typeof(string)));
dt.Columns.Add(new DataColumn("Birthday", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Phone",typeof(string)));
dt.Columns.Add(new DataColumn("Mobile", typeof(string)));
dt.Columns.Add(new DataColumn("Address",typeof(string)));
dt.Columns.Add(new DataColumn("Code",typeof(string)));
}
public void add(int id,string name,DateTime birthday,string phone,string mobile,string address,string code)
{
DataRow dr = dt.NewRow();
dr["Id"] = Convert.ToInt32(id);
dr["Name"] = name;
dr["Birthday"] = Convert.ToDateTime(birthday);
dr["Phone"] = phone;
dr["Mobile"] = mobile;
dr["Address"] = address;
dr["Code"] = code;
id= Convert.ToInt32(LitId.Text.ToString());
name = LitName.Text.ToString();
birthday= Convert.ToDateTime(LitBirthday.Text.ToString());
phone = LitPhone.Text.ToString();
mobile= LiteMobile.Text.ToString();
address= LitAddress.Text.ToString();
code= Litcode.Text.ToString();
dt.Rows.Add(dr);
}
}
补充:.NET技术 , C#