Link to home
Start Free TrialLog in
Avatar of michael1174
michael1174Flag for United States of America

asked on

Reference the selected value in a drop down list in c# ASP.NET

How do I reference the selected value in a drop down list?  I need to use that value to populate a textbox:

Here is my sql string that I am building:

strSQL = "SELECT T1T1DS " +
"FROM XGGNDCT.ZHT1DF00 " +
"WHERE T1T1CD = '" + ddlInsuredOperations value + "'";

After I run the sql, I would reference the field:

txtInsuredOperations.Text = dr4["T1T1DS"].ToString();


Thanks in advance...

Avatar of Raju Srivatsavaye
Raju Srivatsavaye
Flag of United States of America image

You can use ddlInsuredOperations.Text
Avatar of michael1174

ASKER

I get error:

 'System.Web.UI.WebControls.DropDownList' does not contain a definition for 'Text'
Avatar of RealMrTea
RealMrTea

Post the code where you are calling ddInsuredOperations.Text.

strSQL = "SELECT T1T1DS " +
"FROM XGGNDCT.ZHT1DF00 " +
"WHERE T1T1CD = '" + ddlInsuredOperations.Text + "'";

I just tried ddlInsuredOperations.SelectedItem.Value and that looks like its working for me.
ASKER CERTIFIED SOLUTION
Avatar of Vee_Mod
Vee_Mod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial