日期:2014-05-18  浏览次数:20376 次

Dropdownlist数据绑定不上
DAL层是这样写的
C# code
public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select NewsTypeID,NewsType ");
            strSql.Append(" FROM Accounts_NewsType ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return SQLHelper.Query(strSql.ToString());
        }

BLL层是这样写的
C# code
public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
public DataSet GetAllList()
        {
            return GetList("");
        }


页面的cs是这样的
C# code
private void BindNewsType()
    {
        BLL.Accounts_NewsType bll = new BLL.Accounts_NewsType();
        DataSet ds = bll.GetAllList();
        this. NewsType.DataSource = ds.Tables[0];
        this.NewsType.DataTextField = "NewsType";
        this.NewsType.DataValueField = "NewsTypeID";
        this.NewsType.DataBind();

    }

这样数据显示不出来不知道为什么

------解决方案--------------------
你的sql语句的where子句有问题吧
你自己在cmd下运行一下你的sql,应该不正确的吧