using System;
using System.Data;
using System.Data.OleDb;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace www
{
public class MyCodeBehind : Page
{
public DataGrid MyList;
public DataGrid MyList1;
private void Page_Load(Object sender, EventArgs e)
{
if(!IsPostBack)
{
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source="+ Server.MapPath("new.mdb"));
OleDbDataAdapter myCommand = new OleDbDataAdapter("select top 12 aa.* FROM aa WHERE typeid=1 order by shijian desc", myConnection);
OleDbDataAdapter myCommand1 = new OleDbDataAdapter("select top 12 aa.* FROM aa WHERE typeid=2 order by shijian desc", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "aa");
myCommand1.Fill(ds, "bb");
MyList.DataSource = ds.Tables["aa"].DefaultView;
MyList1.DataSource = ds.Tables["bb"].DefaultView;
MyList.DataBind();
MyList1.DataBind();
}
}
protected string FormatString(string str)
{
str=str.Replace(" ","  ");
str=str.Replace("<","&lt;");
str=str.Replace(">","&gt;");
str=str.Replace('/n'.ToString(),"<br>");
return str;
}
}
}