I have a FormView (bound to an ObjectDataSource) that contains a CheckBoxList that I'd like to bind to a single property of the underlying object that is an Enum with the FlagsAttribute applied to it. Binding to the SelectedValue property always gives me just the FIRST selected value from the list as the property's value. Anyone know how to get around this without overriding the Inserting or Updating methods and manually getting the values of the checkbox list and stuffing it into the parameters of the datasource? Sample code below of what I'm trying to do...
<asp:FormView runat="server" ID="MyFormView" DataSourceID="MyDataSource">
<InsertItemTempate>
<asp:CheckBoxList runat="server" ID="MyCbl" SelectedValue='<%# Bind("MyProperty") %>'>
<asp:ListItem Text="Choice 1" Value="ChoiceOne"></asp:ListItem>
<asp:ListItem Text="Choice 2" Value="ChoiceTwo"></asp:ListItem>
</asp:CheckBoxList>
</InsertItemTemplate>
</asp:FormView>
<asp:ObjectDataSource runat="server" ID="MyDataSource" TypeName="MyClass" ...></asp:ObjectDataSource>
behind the scenes, my object is declared like this...
public class MyClass
{
public MyEnum MyProperty { get; set; }
}
[Flags()]
public Enum MyEnum
{
ChoiceOne = 1,
ChoiceTwo = 2
}