首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

数据绑定解决办法

2012-01-12 
数据绑定CS文件protectedvoidPage_Load(objectsender,EventArgse){if(!Page.IsPostBack){OleDbConnectionc

数据绑定
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();

表名不对

热点排行