数据绑定
CS文件
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
OleDbConnection con = Accessx.createCon();
OleDbDataAdapter sdr = new OleDbDataAdapter();
sdr.SelectCommand= new OleDbCommand( "SELECT TOP 5 ID,title, BigClassName,hits, infotime FROM News ORDER BY infotime DESC ",con);
sdr.SelectCommand.Connection = con;
DataSet ds=new DataSet();
sdr.Fill(ds, "nee ");
this.Repeater1.DataSource = ds.Tables[ "neee "];
this.Repeater1.DataBind();
}
ascx文件
<asp:Repeater ID= "Repeater1 " runat= "server ">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "BigClassName ")%>
</ItemTemplate>
</asp:Repeater>
为什么页面上什么都没有啊~~~郁闷啊
------解决方案--------------------sdr.Fill(ds, "nee "); //nee
this.Repeater1.DataSource = ds.Tables[ "neee "]; //neee -> nee?
------解决方案--------------------sdr.Fill(ds, "nee ");
this.Repeater1.DataSource = ds.Tables[ "neee "];
this.Repeater1.DataBind();
表名不对