G
Guest
I have a C# asp.net webform that contains a dropdownlist and a button that
allows the user to select another item in the dropdownlist. The webform
should work as follows:
When the user selects an item in the dropdownlist and clicks the button, his
selection will appear as a line of text somewhere in the webform. The user
can then select another item and clicks the button and his selection will
again appear as a line of text.
In order to avoid duplication, I need to remove (or disable) the selected
item from the dropdownlist. That way, the user wont be able to select an item
that he previously selected. I need to do this without modifying the
database. My code follows and thanks in advance.
string sCCI = "SELECT activity_no,des1
category,Convert(activity_uom,'US7ASCII') bill_rate "
+ "FROM pa_activity "
+ "WHERE (activity_no LIKE Upper('D0%') or activity_no LIKE Upper('S0%'))
And last_status <> 'D' "
+ " And activity_type = 'L' "
+ "ORDER BY des1 ";
OracleConnection oraConn = new OracleConnection(connStr);
OracleCommand oraCMD = new OracleCommand(sCCI, oraConn);
oraConn.Open();
OracleDataAdapter adapter = new OracleDataAdapter(oraCMD);
DataSet ds = new DataSet();
adapter.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
ddlConsultantCategory.DataSource = ds.Tables[0];
ddlConsultantCategory.DataTextField = "category";
ddlConsultantCategory.DataValueField = "category";
ddlConsultantCategory.DataBind();
ddlConsultantCategory.Items.Insert(0, "(Select Consultant Category)");
}
oraConn.Close();
where ddlConsultantCategory is the dropdownlist.
allows the user to select another item in the dropdownlist. The webform
should work as follows:
When the user selects an item in the dropdownlist and clicks the button, his
selection will appear as a line of text somewhere in the webform. The user
can then select another item and clicks the button and his selection will
again appear as a line of text.
In order to avoid duplication, I need to remove (or disable) the selected
item from the dropdownlist. That way, the user wont be able to select an item
that he previously selected. I need to do this without modifying the
database. My code follows and thanks in advance.
string sCCI = "SELECT activity_no,des1
category,Convert(activity_uom,'US7ASCII') bill_rate "
+ "FROM pa_activity "
+ "WHERE (activity_no LIKE Upper('D0%') or activity_no LIKE Upper('S0%'))
And last_status <> 'D' "
+ " And activity_type = 'L' "
+ "ORDER BY des1 ";
OracleConnection oraConn = new OracleConnection(connStr);
OracleCommand oraCMD = new OracleCommand(sCCI, oraConn);
oraConn.Open();
OracleDataAdapter adapter = new OracleDataAdapter(oraCMD);
DataSet ds = new DataSet();
adapter.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
ddlConsultantCategory.DataSource = ds.Tables[0];
ddlConsultantCategory.DataTextField = "category";
ddlConsultantCategory.DataValueField = "category";
ddlConsultantCategory.DataBind();
ddlConsultantCategory.Items.Insert(0, "(Select Consultant Category)");
}
oraConn.Close();
where ddlConsultantCategory is the dropdownlist.