0
我有一個問題將返回參數傳遞給第二個下拉列表。第二個列表完全依賴於第一個列表中的選擇。我很確定SP很好。再次,我的問題是傳遞價值。從屬下拉列表。從一個列表過濾到另一個列表
存儲過程
PROCEDURE ev_dropdown(
cur_out IN OUT eqpack.t_cur_out,
p_result OUT VARCHAR2,
p_reference_id IN NUMBER
)
IS
BEGIN
OPEN cur_out FOR
SELECT ev_id, ev
FROM event WHERE a_ref = p_reference_id;
EXCEPTION
WHEN OTHERS
THEN
p_result :=
'An error occurred in get_events_dropdown - ' || SQLERRM;
END ev_dropdown;
的.cs
public void populateSpecificEv(int p)
{
DataTable dtRef = CreateReferenceDT();
string conn = GetConnectString();
using (OracleConnection connection = new OracleConnection(conn))
using (OracleCommand command = connection.CreateCommand())
{
command.CommandText = "eqpackage.get_events_dropdown";
command.CommandType = CommandType.StoredProcedure;
command.Parameters["p_reference_id"].Value = p;
OracleDataReader reader;
reader = command.ExecuteReader();
dtRef.Rows.Add("0", "-select-");
while (reader.Read())
{
dtRef.Rows.Add(reader[0], reader[1]);
}
connection.Open();
command.ExecuteNonQuery();
command.Connection.Close();
command.Connection.Dispose();
return dtRef; //Error -returns void, a return keyword must not be followed by an object expression
}
}
DataTable CreateReferenceDT()
{
DataTable dt = new DataTable();
dt.Columns.Add("id", typeof(int));
dt.Columns.Add("name", typeof(string));
return dt;
}
aspx.cs
protected void ddlSys_SelectedIndexChanged1(object sender, EventArgs e)
{
int p = int.Parse(ddlSystems.SelectedItem.Value);
dbase.populateSpecificEvent(p);
DataTable dt1 = dbase.PopulateEvDropDown();
ddlEv.DataSource = dt1;
ddlEv.DataTextField = "name";
ddlEv.DataValueField = "id";
ddlEv.DataBind();
}