我有Repeater綁定方法此方法通過存儲過程從數據庫中檢索數據,當Model_Id傳遞給此方法時,它將檢索數據,當用戶多次選擇DDL時,用戶可以多次重複中繼器。我做的代碼,我添加哪些用戶從DDL在數組列表,但錯誤選擇所有Model_Ids出現無法將數組列表轉換爲字符串
不能數組列表轉換爲字符串值:
protected void Add_Click(object sender, ImageClickEventArgs e)
{
ArrayList Array = new ArrayList();
Array.Add(DDLModel.SelectedValue);
DLHome.DataSource = Cls.GetModelName(Array);
DLHome.DataBind();
}
public DataTable GetModelName(string Model_Id)
{
using (SqlConnection conn = Connection.GetConnection())
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetComparisonModel";
SqlParameter ParentID_Param = cmd.Parameters.Add("@Model_Id", SqlDbType.Int);
ParentID_Param.Value = Model_Id;
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(dt);
return dt;
}
}