Reputation: 612
I have a DropDownList whose SelectedValue and DataSource are both databound. The control always selects the first item in the list regardless of the SelectedValue. The correct value is passed to the database when updating the value but the first item is always selected. What am I missing here?
<asp:DropDownList ID="SendAsDdl" runat="server"
SelectedValue='<%# Bind("SendAsId") %>' EnableViewState="true"
DataSource='<%# CM.Email.Users.GetSendAsList(OfficeId) %' />
Upvotes: 1
Views: 411
Reputation: 83356
You can't put scriplets into server side controls. You have to set the SelectedValue from your code behind:
SendAsDdl.SelectedValue = this.SendAsId;
Upvotes: 1