Did any of you guys know that the DropDownList control has a new property in VS.NET 2003? It's called SelectedValue, and it gets the value of the selected item, or sets the value to an item based on a string.


This was my biggest pet peeve with 1.0... there was no simple way to accomplish this, and nonexistent documentation from MS about it. I'm still in shock. Thanks MS!


  • A coworker pointed that out to me the other day. This, of course, was after I had created my own methods in my Multi-Text List Controls to handle such things.

  • Yah, it is great, except for the fact that it makes your compiled source incompatible with the 1.0 framework, so you can't use it anyway if you are concerned about someone running on top of 1.0.

  • I'm using it now, though I never realized it wasn't in before.

    I never used the DropDownList much before, mostly because I never quite figured out how to elegantly use it when binding to an XmlNodeList. DataTextField etc expect a string that maps directly to a property on the DataItem.

    Sure, I could load the xml into a DataSet and bind it to the table's dataview, but that always seemed a little bloated to me. I tended to use a select runat="server" and a repeater to generate the options. Gives you more control anyways.

    I don't have a 1.0 install handy (or the docs), but I assume there was still an SelectedItem property. From a get perspective, this.Dropdown.SelectedItem.Value is not much worse than this.Dropdown.SelectedValue. I assume your main complaint was that it was settable?

  • Yeah, my point was that it was settable. I had to create a custom control to handle it in 1.0....

  • *That* was your biggest pet peeve? :p


  • SelectedValue and SelectedText have always been in the WindowsForms Controls. Good to see ASP.NET thought it was a good idea too! ;)

    I'm in the crowd that never knew it *wasn't* there.

  • VS appears to not like its own code. I did a databind to "selectedvalue". Code appeared in the HTML as follows:

    asp:DropDownList id="ddlbBusUnitSubset" style="Z-INDEX: 113; LEFT: 720px; POSITION: absolute; TOP: 96px" runat="server" Width="216px" SelectedValue='<%# DataBinder.Eval(dsPromotions1, "Tables[PromoHeader].DefaultView.[0].BusUnitSubsetID") %>'>


    But it appeared to reject its own code. There was a squiggly line under "SelectedValue" which on mouseover said, "Could not find any attribute 'SelectedValue' of element 'DropDownList'"

    Have you ever seen this? Functionally it is NOT working. I've reinstalled the Framework and VS but still have the same symptom on two different machines.

    Any Ideas?


  • We have written a VB.Net / ASP.Net application using Visual Studio .Net 2003. Several pages use the SelectedItem property of the DropDownList. All of the desktops except one work fine, and I cannot find a difference in the installs.

    On the offending desktop, at edit time, DropDownList gives you the type-ahead help that prompts you for the SelectedItem property.

    But at run time, it throws the error message

    'SelectedValue' is not a member of 'DropDownList'.

    This is true if I set a breakpoint and type


    in the immediate window or if I enter that desktop's I.P. address into a browser window and use its instance of IIS.

    Any idea what component is out-of-date (probably from an older .Net Framework and where it would be located?)

    I tried downloading the current .Net Framework and reinstalling and removed and added all references in the project, with no change.

Comments have been disabled for this content.