日期:2014-05-18 浏览次数:20612 次
namespace Mysite.Business { /// <summary> /// Category 的摘要说明 /// </summary> public class Category { DBOperate dboperate = newasp:Button
public partial class admin_manager_Edit : System.Web.UI.Page
{
Category category = new Category();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ddl_category.DataSource = category.Bind_category();
ddl_category.DataBind();
}
}
}
namespace Mysite.Business { /// <summary> /// Category 的摘要说明 /// </summary> public class Category { DBOperate dboperate = new DBOperate(); public Category() { // // TODO: 在此处添加构造函数逻辑 // } /// <summary> /// 绑定下拉列表框 /// </summary> /// <param name="ddl">DropDownList控件名称</param> public DataTable Bind_category() { string strSql = "select xm_name from tb_tree where left(ltrim(keytxt),2)='2_'"; OleDbDataAdapter oda = new OleDbDataAdapter(strSql, dboperate.cn); DataSet ds = new DataSet(); oda.Fill(ds); //ddl.DataSource = ds.Tables[0]; return ds.Tables[0].DefaultView; } } }
------解决方案--------------------
public partial class admin_manager_Edit : System.Web.UI.Page
{
Category category = new Category();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ddl_category.DataSource = category.Bind_category();
ddl_category.DataTextField = "text column";
ddl_category.DataValueField = "value column";
ddl_category.DataBind();
}
}
}
------解决方案--------------------
public partial class admin_manager_Edit : System.Web.UI.Page { Category category = new Category(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddl_category.DataSource = category.Bind_category(); ddl_category.DataTextField = "text column"; ddl_category.DataValueField = "value column"; ddl_category.DataBind(); } } }
------解决方案--------------------