
怎么实现asp.NET数据绑定,在点条件查询时才出现数据,不点就不出现呢?
展开全部
可能是你数据查询条件判断有误吧!
string sql = "select * from news";
if (NewsTypeId > 0)
sql += " where news.typeId = " + NewsTypeId;
DataSet ds = DBHelper.PageOrder(pgMain.PageSize * (pgMain.CurrentPageIndex - 1), pgMain.PageSize, sql);//每页显示的数据源
pgMain.RecordCount = DBHelper.PageOrder(0, 0, sql).Tables[0].Rows.Count;//总数
this.pgMain.CustomInfoHTML = string.Format("当前第{0}/{1}页 共{2}条记录 每页{3}条", new object[] { this.pgMain.CurrentPageIndex, this.pgMain.PageCount, this.pgMain.RecordCount, this.pgMain.PageSize });
this.dlNews.DataSource = ds;
this.dlNews.DataBind();
string sql = "select * from news";
if (NewsTypeId > 0)
sql += " where news.typeId = " + NewsTypeId;
DataSet ds = DBHelper.PageOrder(pgMain.PageSize * (pgMain.CurrentPageIndex - 1), pgMain.PageSize, sql);//每页显示的数据源
pgMain.RecordCount = DBHelper.PageOrder(0, 0, sql).Tables[0].Rows.Count;//总数
this.pgMain.CustomInfoHTML = string.Format("当前第{0}/{1}页 共{2}条记录 每页{3}条", new object[] { this.pgMain.CurrentPageIndex, this.pgMain.PageCount, this.pgMain.RecordCount, this.pgMain.PageSize });
this.dlNews.DataSource = ds;
this.dlNews.DataBind();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询