Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

specifying datavaluefield in ddlb

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SandpointGuy - 27 Sep 2007 20:17 GMT
I have a dropdown of states that is populated from a table, that looks like
ddlb.DataValueField="StateCode" // ex: FL
ddlb.DataTextField="StateDescription" // ex: Florida

If I want to set the initial value I can use
ddlb.SelectedValue="Florida"
In other words, SelectedValue is the DataTextField

How do I set the initial value to the DataValueField?
ddlb.SelectedValue="FL" doesnt work (or is it just me?)

Thanks, Mark
Mike - 27 Sep 2007 20:20 GMT
you can do

dd.SelectedText = "FL";

is the value for Florida acutally FL?

Mike

>I have a dropdown of states that is populated from a table, that looks like
> ddlb.DataValueField="StateCode" // ex: FL
[quoted text clipped - 8 lines]
>
> Thanks, Mark
SandpointGuy - 27 Sep 2007 20:43 GMT
There is no SelectedText property for the drop down list box.

> you can do
>
[quoted text clipped - 16 lines]
> >
> > Thanks, Mark
Mike - 27 Sep 2007 20:56 GMT
try this:
dd.SelectedItem.Text = "FL";

or if you know the index number of Fl you can do

dd.SelectedIndex = 5 (or whatever FL is)

Mike

> There is no SelectedText property for the drop down list box.
>
[quoted text clipped - 19 lines]
>> >
>> > Thanks, Mark
SandpointGuy - 27 Sep 2007 21:28 GMT
Actually, SelectedItem.Value is closer to what I want.  But it adds a new
entry at the top, rather than selecting the existing value of "FL"

In other words, I get :
<option value="FL" selected="selected" value="FL">Alabama
<option value="AL">Alabama
... other states
<option value="FL">Florida

And what I want is:
<option value="FL" selected="selected">Florida
<option value="AL">Alabama
... other states

> try this:
> dd.SelectedItem.Text = "FL";
[quoted text clipped - 28 lines]
> >> >
> >> > Thanks, Mark

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.