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

求高手!解决办法

2012-03-24 
求高手!!using Systemusing System.Collections.Genericusing System.Linqusing System.Webusing Syst

求高手!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class photoAlbum : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  { 
  if (!IsPostBack)
  {
  Bing();
  }
  }
  public void Bing()
  {
  string SQL = "select * from TypeIMG ";
  Jerry.SQLServer db = new Jerry.SQLServer();
  DataSet ds = db.select(SQL);
  Repeater1.DataSource = ds.Tables["content"].DefaultView; Repeater1.DataBind();
  }
}


运行时出现未将对象引用设置到对象的实例。到底是哪里出现错误了啊????

[解决办法]

探讨
if(ds !=null)
{
Repeater1.DataSource = ds.Tables[0].DefaultView;
Repeater1.DataBind();

}

[解决办法]
C# code
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;public partial class photoAlbum : System.Web.UI.Page{   protected void Page_Load(object sender, EventArgs e)   {      if (!IsPostBack)     {        Bing();     }  }  public void Bing()  {      string SQL = "select * from TypeIMG ";      Jerry.SQLServer db = new Jerry.SQLServer();      DataSet ds = db.select(SQL);      Repeater1.DataSource = ds;      Repeater1.DataBind();   }} 

热点排行