从数据库中将信息绑定到DropDownList控件中

必须引用using System.Data.SqlClient 
            SqlConnection  con = new SqlConnection("server=.;database=oa;user id=sa;pwd=;");
            SqlCommand cmd = new SqlCommand("select * from OA_CRM_DWXZZD",con );
            con.Open();
            DropDownList1.DataSource = cmd.ExecuteReader();
            DropDownList1.DataTextField = "MC";
            DropDownList1.DataBind();
            con.Close();
posted on 2008-01-11 10:55  sherry  阅读(262)  评论(0编辑  收藏  举报