dropdownlist question

G

Guest

i have a dropdownlist that should allow the user to select a state. it should
display the 2-letter state code and the full state name. for example:

AK Alaska
CA California
....

but i am only able to display either the 2-letter state code or the full
state name (not both). my code follows:

string StCd = "SELECT DISTINCT(State_Code) stateID, Des1 state FROM
Sy_State_Code where State_Code <> 'OTH' and State_Code <> 'AA' and State_Code
<> 'AE' and State_Code <> '-'Order By State_Code ";
//stateUD is the 2-letter state code and Des1 is the full state name

oraCMD = new OracleCommand(StCd, oraConn);
oraConn.Open();
OracleDataAdapter da5 = new OracleDataAdapter(oraCMD);
DataSet ds5 = new DataSet();
da5.Fill(ds5);
if (ds5.Tables[0].Rows.Count > 0)
{
ddlState.DataSource = ds5.Tables[0];
ddlState.DataTextField = "state";
ddlState.DataValueField = "stateID";
ddlState.DataBind();
ddlState.Items.Insert(0, "(Select a State Code)");
}
da5.Dispose();
oraConn.Close();

thanks in advance
 
G

Guest

Change the query as
string StCd = "SELECT DISTINCT(State_Code), State_Code + ' ' + Des1 state
FROM Sy_State_Code where State_Code <> 'OTH' and State_Code <> 'AA' and
State_Code <> 'AE' and State_Code <> '-'Order By State_Code ";
 
G

Guest

i made the change and now i'm getting an "ORA-01722: invalid number" exception.

AMALORPAVANATHAN YAGULASAMY(AMAL)MCP said:
Change the query as
string StCd = "SELECT DISTINCT(State_Code), State_Code + ' ' + Des1 state
FROM Sy_State_Code where State_Code <> 'OTH' and State_Code <> 'AA' and
State_Code <> 'AE' and State_Code <> '-'Order By State_Code ";

--
Regards,
Amal [MCP, MCS]
http://geocities.com/techsharing


Newbie said:
i have a dropdownlist that should allow the user to select a state. it should
display the 2-letter state code and the full state name. for example:

AK Alaska
CA California
...

but i am only able to display either the 2-letter state code or the full
state name (not both). my code follows:

string StCd = "SELECT DISTINCT(State_Code) stateID, Des1 state FROM
Sy_State_Code where State_Code <> 'OTH' and State_Code <> 'AA' and State_Code
<> 'AE' and State_Code <> '-'Order By State_Code ";
//stateUD is the 2-letter state code and Des1 is the full state name

oraCMD = new OracleCommand(StCd, oraConn);
oraConn.Open();
OracleDataAdapter da5 = new OracleDataAdapter(oraCMD);
DataSet ds5 = new DataSet();
da5.Fill(ds5);
if (ds5.Tables[0].Rows.Count > 0)
{
ddlState.DataSource = ds5.Tables[0];
ddlState.DataTextField = "state";
ddlState.DataValueField = "stateID";
ddlState.DataBind();
ddlState.Items.Insert(0, "(Select a State Code)");
}
da5.Dispose();
oraConn.Close();

thanks in advance
 

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 3
dropdownlist question 2
synchronization 2

Top