I have a drop down list that is being used in an EditItemTemplate of a DetailsView, and it is being populated from a SqlDataSource, and I am binding the selected value as follows:
<EditItemTemplate>
<asp:DropDownList ID="lstLocations" runat="server"
DataSourceID="sqlMDALocationsAll" DataTextField="loc_name" DataValueField="id"
SelectedValue='<%# Bind("staff_location_id") %>' AppendDataBoundItems="True" >
<asp:ListItem Value="">(Unknown)</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
All works as expected. Now what I want to do is enable only those bound list items based on another column in the sqlDataSource - there is a "status" column that can have values of either active or inactive - and if the status of an entry is active, then I want the corresponding list item to be enabled, otherwise I want it to be disabled. The reason is that since this is an edit form, I don't want people to be able to select a value that is inactive, but I need to include those "inactive" entries in the drop down list, since the main entry that is being edited could well have a location id for a location that is now inactive.
What I tried to use was the following atted to the DropDownList definition:
Enabled='<%# Eval("status") = "active" %>'
But that didn't work - but there weren't any errors reported.
Any suggestions?
Thanks