dropdownlist

G

Guest

I need to populate a dropdownlist that will show two entries (title and
billing rate) for each item. Example:

Programmer $50
Engineer $50
....

Right now I'm only able to show the title but not the rate. My code follows:

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();
 
S

Sanjay Pais

First off, your your property settings seem to be incorrect:
ddlConsultantCategory.DataTextField = "category";
ddlConsultantCategory.DataValueField = "category";
The data Text field seems to be the same as the DataValue field.

Secondly change you SQL to Select the Title and Billing Rate into a single
column and set this as the DataTextField. You can then set some other unique
column as the datavalue field

Sanjay
 
C

critter

I think there are several possible ways to accomplish what you are
trying to do, so please don't take this suggestion as the only way to
do it.

It seems like the easiest solution is to create a calculated field in
your select statement where you combine the category and bill_rate into
a single field (Select (des1+' '+bill_rate) as myfield, ....)(I'm more
familiar with mssql than oracle so forgive me if the syntax of the
select statement doesnt work for oracle). Once you have the calculated
field in your dataset, change your ddlConsultantCategory.DataTextField
from "category" to "myfield" or whatever you name the field.

Hope it helps
 
G

Guest

I'm getting the exception:
ORA-00907: missing right parenthesis

Code:

string sCCI = "SELECT activity_no, (des1 title + '-' + bill_rate) category "
+ "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 = "title";
ddlConsultantCategory.DataBind();
ddlConsultantCategory.Items.Insert(0, "(Select Consultant Category)");
}
oraConn.Close();



Sanjay Pais said:
First off, your your property settings seem to be incorrect:
ddlConsultantCategory.DataTextField = "category";
ddlConsultantCategory.DataValueField = "category";
The data Text field seems to be the same as the DataValue field.

Secondly change you SQL to Select the Title and Billing Rate into a single
column and set this as the DataTextField. You can then set some other unique
column as the datavalue field

Sanjay

Newbie said:
I need to populate a dropdownlist that will show two entries (title and
billing rate) for each item. Example:

Programmer $50
Engineer $50
...

Right now I'm only able to show the title but not the rate. My code
follows:

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();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

dropdownlist question 2
synchronization 2
printing a datagrid 2
dropdownlist question 2

Top