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();
}
}
运行时出现未将对象引用设置到对象的实例。到底是哪里出现错误了啊????
------解决方案--------------------
1楼给的是容错
string SQL = "select * from TypeIMG";也就是没得数据,你看看ds读取到数据没有,看一下ds.Table[0].Rows.Count
------解决方案--------------------
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();
}
}