I am binding a detailsview to a datasource and wish to use a drop down list (ddl) for one of the fields. It is fine to bind the ddl to another datasource but I couldnt get the selectedvalue to be set due to errors like: ‘SelectedValue’ property cannot be set declaratively.
In the ide you can’t set SelectedValue using intellisense or the properties window (which makes you think it isnt a valid property). BUT you can set it using the databindings window of the ddl (click the arrow to the right of the control and choose “edit databindings”.) BUT you will still get the above error if you try to use Bind or eval.
The solution: In the source use the following syntax:
SelectedValue=’<%# Bind(“TypeID”) %>’
USE SINGLE QUOTES!!!! It doesnt work if you use double quotes. I dont know why this works I imagine it is because of a pre-validator which ignores single quotes. I’m using VS 2008.