Sep 29, 2009, 6:15 AM
ComboBox's SelectedItem in MVC App
Okay, I think I'm stuck. I have ComboBox that its initial value is set from the controller but the combo's value always blank.
Controller :
Controller :
Function Form() As ActionResult
ViewData("SEX") = "F"
Return View()
End Function
View :<ext:ComboBox runat="server" ID="cbSEX" FieldLabel="SEX">
<Items>
<ext:ListItem Text ="Male" Value="M" />
<ext:ListItem Text ="Female" Value="F" />
</Items>
<SelectedItem Value='<%# ViewData("SEX") %>' AutoDataBind="true" />
</ext:ComboBox>
Anyway, it works fine if I set the selecteditem manually, e.g. <SelectedItem Value="M" />
Anybody here have any idea?