前台页:
<%# DataBinder.Eval(Container.DataItem,"id") %>
<%# DataBinder.Eval(Container.DataItem, "kind")%>
后台页:
SqlConnection conn = DB.createConn();
SqlCommand cmd = new SqlCommand("select * from newskinds", conn);
conn.Open();
SqlDataReader read = cmd.ExecuteReader();
DataTable da = new DataTable();
da.Columns.Add("id",typeof(int));
da.Columns.Add("kind",typeof(string));
while (read.Read())
{
DataRow dr = da.NewRow();
dr["id"] = read["newsKindID"].ToString();
dr["kind"] = read["kindName"].ToString();
da.Rows.Add(dr);
}
this.DataList1.DataSource = da;
this.DataList1.DataBind();