I am using ASP.NET 2.0 and Visual Studio 2005.
I have a DetailsView that the user can use to view and edit a record. One of these fields has only 7 possible values, so in edit mode, I want to switch to a dropdownlist. I had no problems doing this. I changed to a template field, then changed the textbox to a dropdownlist.
What I want to do now is set the SelectedValue of that dropdownlist to match the existing value of the record being edited, but for the life of me, I can't figure out how to do this.
First, I am confused about whether SelectedValue should be showing up as a property of asp:dropdownlist in the page design (not code behind). For me, it doesn't. I have seen many posts suggesting something like SelectedValue='<%# Bind("OrgType") %>' and assume that either this construction is not available in asp.net 2.0 or that I have a bad setting somewhere.
I have tried a few variations of FindControl, but nothing I've tried is working, including some suggestions from a similar post earlier today:
My Detailsview is called DetailsView1. The DropDownList (DropDownList1) is in the <EditItemTemplate>. Label7 is used in the <ItemTemplate>. The Text and Value properties for the seven items in the dropdownlist are identical text values.
Thanks for any suggestions.
Chris