我正在嘗試做一個汽車維修項目,而且我有一個小問題。該項目是這樣的:dropdownlist從SQL數據庫中選擇
4種不同的汽車維修計劃。
CarA (MirrorA, etc etc)
CarB (MirrorB, etc etc)
CarC (MirrorC, etc etc)
CarD (MirrorD, etc etc)
我想要做的是,當我選擇了一個Car
(從DropDownList
),程序選擇正確的維護計劃的車!
SqlCommand cmd = new SqlCommand("Select id, description from accauto_maps", con);
con.Open();
DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataTextField = "description";
DropDownList1.DataValueField = "id";
DropDownList1.DataBind();
現在我卡住了。
你有自動回設置爲true?這是你所有的代碼還是更多? – Maximus2012 2015-03-31 17:51:14
在相同的代碼塊中查看DropDownList和SqlCommand會使我的眼睛受傷。 – granadaCoder 2015-03-31 18:38:26
你能詳細說一下,你的小問題是什麼?你到底在哪裏? – wonderbell 2015-03-31 19:01:05