我不得不降下來,其執行代碼列表時,特定的條件,我試圖通過選擇值來檢查它,但它得到錯誤下拉列表中選中
protected void DDLProductFamily_SelectedIndexChanged(object sender, EventArgs e)
{
if (DDLProductFamily.Items.FindByText("Name").Selected == true)
using (SqlConnection Con = Connection.GetConnection())
{
SqlCommand Com = new SqlCommand("GetListViewByProductCategory", 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();
}
else if (DDLProductFamily.Items.FindByText("ProductFamilly").Selected == true)
{
using (SqlConnection Con = Connection.GetConnection())
{
SqlCommand Com = new SqlCommand("GetListViewByProductFamily", Con);
Com.CommandType = CommandType.StoredProcedure;
Com.Parameters.Add(Parameter.NewInt("@ProductFamily_Id", DDLProductFamily.SelectedValue.ToString()));
SqlDataAdapter DA = new SqlDataAdapter(Com);
DA.Fill(dt);
DataList1.DataSource = dt;
DataList1.DataBind();
}
}
}
而錯誤是? – womp 2010-04-19 16:06:15
對象引用不是實例..... – Myworld 2010-04-19 16:16:26
您應該包含(至少一部分)堆棧跟蹤。有任何數量的東西都可能無效。 – R0MANARMY 2010-04-19 16:20:00