我要修改数据,在DropDownList显示该修改数据一个分类,这个要怎么绑定?

解决方案 »

  1.   

    DropDownList1.DataSource = datatable;
    DropDownList1.DataTextField = "classname";
    DropDownList1.DataValueField = "classid";
    DropDownList1.DataBind();
      

  2.   

    string strSQL = "select * from zclx where lb='1'";
    SqlDataReader dr = GetData.GetReadbySQL(strSQL);
    ddlZclx.DataSource = dr;
    ddlZclx.DataTextField = "mc";
    ddlZclx.DataValueField = "lb";
    ddlZclx.DataBind();
      

  3.   

    我对ADO.NET的一点都不懂,这个(SqlDataReader dr = GetData.GetReadbySQL(strSQL);)
    是做什么的?
    private void Departments_List_bind()
            {
                string strSQL = "select * from Departments where Id=" + Request.QueryString["Id"].ToString() + " ";
                SqlDataReader dr = GetData.GetReadbySQL(strSQL);
                Departments_List.DataSource = dr;
                Departments_List.DataTextField = "Classname";
                Departments_List.DataValueField = "Id";
                Departments_List.DataBind();
            }
    我这样写可以吗?
      

  4.   

    string strSQL = "select * from zclx where lb='1'"; 
    SqlDataReader dr = GetData.GetReadbySQL(strSQL); 
    ddlZclx.DataSource = dr; 
    ddlZclx.DataTextField = "mc"; 
    ddlZclx.DataValueField = "lb"; 
    ddlZclx.DataBind(); 
      

  5.   

    private void Departments_List_bind()
            {
                string strSQL = "select * from Departments where Id=" + Request.QueryString["Classid"].ToString() + " ";
                DataTable dt = DacTools.GetDataSet(strSQL);
                Departments_List.DataSource = dt;
                Departments_List.DataTextField = dt.Rows[0]["Classname"].ToString();
                Departments_List.DataValueField = dt.Rows[0]["Id"].ToString();
                Departments_List.DataBind();
            }
    之前定义了一个类DacTools的
    Departments_List是DropDownList,这样好象显示不出来
      

  6.   

    参考
    http://www.cnblogs.com/torome/articles/300556.html