C#asp.net DropDownList1绑定数据库

C#asp.net__DropDownList1绑定数据库


             System.Data.SqlClient.SqlConnection sqlconn = new System.Data.SqlClient.SqlConnection();
             sqlconn.ConnectionString = lianjie .Text;
             sqlconn.Open();
             System.Data.SqlClient.SqlDataAdapter sqldar = new System.Data.SqlClient.SqlDataAdapter("select * from lanmu",sqlconn);
             sqldar.SelectCommand.CommandType = CommandType.Text;
             System.Data.DataSet DataSet1= new System.Data.DataSet();
             sqldar.Fill(DataSet1,"栏目名称");
             DropDownList1.DataSource = DataSet1.Tables["栏目名称"].DefaultView;
             DropDownList1.DataTextField = "栏目名称";
             DropDownList1.DataBind();
             sqlconn.Close();


webform