关于ASP.NET的DATALIST问题
publicpartialclasstest:System.Web.UI.Page{privatevoidbanddl(){SqlConnectionconn=newSq...
public partial class test : System.Web.UI.Page
{
private void banddl()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"].ConnectionString);
conn.Open();
string cmdtext = "SELECT * FROM [sho]";
SqlDataAdapter sda = new SqlDataAdapter(cmdtext, conn);
DataSet ds=new DataSet();
sda.Fill(ds,"sho");
PagedDataSource pages = new PagedDataSource();
pages.DataSource = ds.Tables["sho"].DefaultView;
pages.AllowPaging = true;
pages.PageSize = 10;
this.DataList1.DataSource = pages;
this.DataList1.DataBind();
conn.Close();
}
protected void Page_Load(object sender, EventArgs e)
{
banddl();
}
}
为什么我这个代码没用,不报错就是打开页面一片空白.没能读出数据..
PS.SHO里绝对有数据.....
谢谢! 展开
{
private void banddl()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"].ConnectionString);
conn.Open();
string cmdtext = "SELECT * FROM [sho]";
SqlDataAdapter sda = new SqlDataAdapter(cmdtext, conn);
DataSet ds=new DataSet();
sda.Fill(ds,"sho");
PagedDataSource pages = new PagedDataSource();
pages.DataSource = ds.Tables["sho"].DefaultView;
pages.AllowPaging = true;
pages.PageSize = 10;
this.DataList1.DataSource = pages;
this.DataList1.DataBind();
conn.Close();
}
protected void Page_Load(object sender, EventArgs e)
{
banddl();
}
}
为什么我这个代码没用,不报错就是打开页面一片空白.没能读出数据..
PS.SHO里绝对有数据.....
谢谢! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询