• 主页
  • ASP
  • .NET Framework
  • Web Services
  • VB
  • VC
  • 图表区
  • 分析与设计
  • 组件/控件开发
  • LINQ
yuyij 南京理工 本科  2014年01月07日
datalist 控件绑定数据不显示,数据库里面不为空
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class desktopmodules_putong : System.Web.UI.Page
{
DataOperate sqlBind = new DataOperate();
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
protected void Page_Load(object sender, EventArgs e)
{
dlbind();
}
public void dlbind() {
string idStr = Page.Request.QueryString["titleid"];
int curpage = Convert.ToInt32(this.labPage.Text);

PagedDataSource ps = new PagedDataSource();
con.Open();
string str = "select * from title_view where titleid='" + idStr + "'";
SqlDataAdapter m = new SqlDataAdapter(str,con);
DataSet ds = new DataSet();
m.Fill(ds,"title");
con.Close();
ps.DataSource = ds.Tables["title"].DefaultView;
ps.AllowPaging = true;
ps.PageSize = 2;
ps.CurrentPageIndex = curpage - 1;
up.Enabled = one.Enabled = back.Enabled = next.Enabled = true;
if(curpage==1){
one.Enabled = false;
up.Enabled = false;
}
if (curpage == ps.PageCount) {
next.Enabled = false;
back.Enabled = false;
}
this.labbackpage.Text = Convert.ToString(ps.PageCount);
this.dl.DataSource = ps;
this.dl.DataKeyField = "titleid";
this.dl.DataBind();

}
protected void one_Click(object sender, EventArgs e)
{
this.labPage.Text = "1";
this.dlbind();
}
protected void up_Click(object sender, EventArgs e)
{
this.labPage.Text = Convert.ToString(Convert.ToInt32(this.labPage.Text)-1);
this.dlbind();
}
protected void next_Click(object sender, EventArgs e)
{
this.labPage.Text = Convert.ToString(Convert.ToInt32(this.labPage.Text)+1);
this.dlbind();
}
protected void back_Click(object sender, EventArgs e)
{
...全文
61 点赞 收藏 5
写回复
5 条回复

还没有回复,快来抢沙发~

发动态
发帖子
.NET技术社区
创建于2007-09-28

4.8w+

社区成员

66.8w+

社区内容

.NET技术交流专区
社区公告
暂无公告