我做了從數據庫中獲取其值的下拉列表,並且在運行應用程序時,該列表無法正常工作,編譯器也沒有看到代碼。已更改下拉列表選定索引
// ASPX
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DDlProductFamily" runat="server"
ondatabound="DDlProductFamily_DataBound"
onselectedindexchanged="DDlProductFamily_SelectedIndexChanged">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DDlProductFamily" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
// CS
protected void DDlProductFamily_SelectedIndexChanged(object sender, EventArgs e)
{
using (SqlConnection Con = Connection.GetConnection())
{
SqlCommand Com = new SqlCommand("SelectThumbByProductFamily", Con);
Com.CommandType = CommandType.StoredProcedure;
Com.Parameters.Add(Parameter.NewInt("@ProductCategory_Id",
DDlProductFamily.SelectedValue.ToString()));
SqlDataAdapter DA = new SqlDataAdapter(Com);
DA.Fill(dt);
DataList1.DataSource = dt;
DataList1.DataBind();
}
}
謝謝你,但在其他問題出現數據列表並沒有得到DDL新的值時,DDL選中 – Myworld 2010-04-19 10:52:51