日期:2014-05-17 浏览次数:20479 次
protected void Page_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); DataColumn col1 = new DataColumn(); col1.ColumnName = "number"; col1.DataType = Type.GetType("System.String"); col1.MaxLength = 10; dt.Columns.Add(col1); for (int i = 0; i < 10; i++) { DataRow dr = dt.NewRow(); dr["number"] = i.ToString(); dt.Rows.Add(dr); } DataList1.DataSource = dt; DataList1.DataBind(); Label entity = DataList1.Items[0].FindControl("Label1") as Label; Label2.Text = entity.Text; }