dropdownlist question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Newbie

    dropdownlist question

    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(S tCd, oraConn);
    oraConn.Open();
    OracleDataAdapt er da5 = new OracleDataAdapt er(oraCMD);
    DataSet ds5 = new DataSet();
    da5.Fill(ds5);
    if (ds5.Tables[0].Rows.Count > 0)
    {
    ddlState.DataSo urce = ds5.Tables[0];
    ddlState.DataTe xtField = "state";
    ddlState.DataVa lueField = "stateID";
    ddlState.DataBi nd();
    ddlState.Items. Insert(0, "(Select a State Code)");
    }
    da5.Dispose();
    oraConn.Close() ;

    thanks in advance
  • AMALORPAVANATHAN YAGULASAMY(AMAL)MCP,MCS

    #2
    RE: dropdownlist question

    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]
    Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!



    "Newbie" wrote:
    [color=blue]
    > 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(S tCd, oraConn);
    > oraConn.Open();
    > OracleDataAdapt er da5 = new OracleDataAdapt er(oraCMD);
    > DataSet ds5 = new DataSet();
    > da5.Fill(ds5);
    > if (ds5.Tables[0].Rows.Count > 0)
    > {
    > ddlState.DataSo urce = ds5.Tables[0];
    > ddlState.DataTe xtField = "state";
    > ddlState.DataVa lueField = "stateID";
    > ddlState.DataBi nd();
    > ddlState.Items. Insert(0, "(Select a State Code)");
    > }
    > da5.Dispose();
    > oraConn.Close() ;
    >
    > thanks in advance[/color]

    Comment

    • Newbie

      #3
      RE: dropdownlist question

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

      "AMALORPAVANATH AN YAGULASAMY(AMAL )MCP,MCS" wrote:
      [color=blue]
      > 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" wrote:
      >[color=green]
      > > 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(S tCd, oraConn);
      > > oraConn.Open();
      > > OracleDataAdapt er da5 = new OracleDataAdapt er(oraCMD);
      > > DataSet ds5 = new DataSet();
      > > da5.Fill(ds5);
      > > if (ds5.Tables[0].Rows.Count > 0)
      > > {
      > > ddlState.DataSo urce = ds5.Tables[0];
      > > ddlState.DataTe xtField = "state";
      > > ddlState.DataVa lueField = "stateID";
      > > ddlState.DataBi nd();
      > > ddlState.Items. Insert(0, "(Select a State Code)");
      > > }
      > > da5.Dispose();
      > > oraConn.Close() ;
      > >
      > > thanks in advance[/color][/color]

      Comment

      Working...