2010年3月4日 星期四

下拉式選單+連結資料庫 c# 版

SqlConnection Conn1 = new SqlConnection(WebConfigurationManager.ConnectionStrings["TestReportConnectionString"].ConnectionString);
SqlDataAdapter da1 = new SqlDataAdapter("select version from product where productName='萬能廚師系列'", Conn1);
DataSet ds1 = new DataSet();
da1.Fill(ds1, "product");
DropDownList3.AutoPostBack = true;
DropDownList3.DataTextField = "version";
DropDownList3.DataValueField = "version";
DropDownList3.DataSource = ds1.Tables["product"].DefaultView;
DropDownList3.DataBind();
Conn1.Close();

沒有留言:

張貼留言