public class DB { public DB() { } /// <summary> /// Method returns a DataSet object filled with data /// </summary> public static DataSet GetDataSet() { //创建dataset和datatable DataSet ds = new DataSet(); DataTable table = new DataTable("Records"); DataColumn col; //增加一个列 col = new DataColumn(); col.DataType = System.Type.GetType("System.Int32"); col.ColumnName = "ID"; col.ReadOnly = true; col.Unique = true; table.Columns.Add(col); col = new DataColumn(); col.DataType = System.Type.GetType("System.String"); col.ColumnName = "Name"; col.AutoIncrement = false; col.Caption = "Name"; col.ReadOnly = false; col.Unique = false; table.Columns.Add(col); col = new DataColumn(); col.DataType = System.Type.GetType("System.String"); col.ColumnName = "Address"; col.AutoIncrement = false; col.Caption = "Address"; col.ReadOnly = false; col.Unique = false; table.Columns.Add(col); //增加一条记录 DataRow row = table.NewRow(); row["ID"] = 1001; row["Name"] = "Melanie Giard"; row["Address"] = "23rd Street, Park Road, NY City, NY"; table.Rows.Add(row); row = table.NewRow(); row["ID"] = 1002; row["Name"] = "Puneet Nehra"; row["Address"] = "3rd Blvd, Ashok Vihar, New Delhi"; table.Rows.Add(row); row = table.NewRow(); row["ID"] = 1003; row["Name"] = "Raj Mehta"; row["Address"] = "Nagrath Chowk, Jabalpur"; table.Rows.Add(row); row = table.NewRow(); row["ID"] = 1004; row["Name"] = "Max Muller"; row["Address"] = "25 North Street, Hernigton, Russia"; table.Rows.Add(row); // Add DataTable to DataSet ds.Tables.Add(table); // Return DataSet return ds; } } |
<%@ Control Language="VB" %> <FONT face="verdana" color="green" size="2"><b>ID: </b> <%# DataBinder.Eval(CType(Container, DataListItem).DataItem, "ID") %> <b>Name: </b> <%# DataBinder.Eval(CType(Container, DataListItem).DataItem, "Name") %> <br> <b>Address: </b> <%# DataBinder.Eval(CType(Container, DataListItem).DataItem, "Address") %> <p> </FONT> |
|