Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text from DropDownList in SqlDataSource ControlParameter

Status
Not open for further replies.

LittlBUGer

Programmer
Apr 26, 2006
81
US
Hello. I have an ASP.NET 2.0 webpage which has a custom new user registration area. Some of the parts include choosing a State, County, and Country, of which I've assigned dropdownlists to handle. Unfortunately, after everything has been chosen and the user clicks on the Register button, it doesn't fully register. I'm using a SqlDataSource to do the insert with some ControlParameters. What I need for those dropdownlists is the text, not the value. If I specify something like this:

Code:
<asp:ControlParameter Name="State" Type="String" ControlID="ddState" PropertyName="Text" />
<asp:ControlParameter Name="County" Type="String" ControlID="ddCounty" PropertyName="Text" />
<asp:ControlParameter Name="Country" Type="String" ControlID="ddCountry" PropertyName="Text" />

It works, but Text is the same as SelectedValue, and I want the actual Text of the dropdownlist. So if I change the PropertyType to SelectedItem.Text, it doens't work. Or if I go to the code behind and try to do this:

Code:
DataSource3.InsertParameters.Add("State", ddState.SelectedItem.Text)
DataSource3.InsertParameters.Add("County", ddCounty.SelectedItem.Text)
DataSource3.InsertParameters.Add("Country", ddCountry.SelectedItem.Text)
DataSource3.Insert()

It doesn't work either. Any ideas on how to make this work? Am I missing something really simple? Thanks. :)

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein
 
If anyone could help me ASAP, I'd be much appreciated. Thank you for your time. :)

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top