G
Giulio Petrucci
Hi there,
I have a Foo class with a property FooType, which is an enum with three
values: X,Y,Z.
At the UI level, the Foo instance editing is performed by a details
view. So I prepared a Dto like this:
class FooDto
{
FooDto()
{
FooDtoType = FooType.X.ToString(); //default;
}
string FooDtoType { get; set; }
IEnumerable<string> FooTypeList
{
get
{
return Enum.GetNames(typeof(FooType));
}
}
}
and my DetailsView will be something like:
<aspetailsView ID="fooDetailsView" runat="server">
<asp:TemplateField HeaderText="FooType" InsertVisible="true">
<EditItemTemplate>
<aspropDownList ID="TypeList" runat="server"
DataSource='<%# Eval("FooTypeList") %>'
HeaderText="Tipo" SelectedValue='<%#
Bind("FooDtoType")%>'>
</aspropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<aspropDownList ID="TypeList" runat="server"
DataSource='<%# Eval("FooTypeList") %>'
HeaderText="Tipo" SelectedValue='<%#
Bind("FooDtoType")%>'>
</aspropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Literal ID="FooType" runat="server" Text='<%#
Eval("FooDtoType") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
</aspetailsView>
If I try to edit an existing FooDto (pushing the DetailsView control in
edit mode) everything works fine and in my field I can see a drop down
list filled with all the enum values. If I try to add a new FooDto
(pushing my DetailsView in insert mode) the drop down list is empty
(despite of having boud the control to a new FooDto instance). What's
wrong with my code?
thanks in advance,
Giulio
--
I have a Foo class with a property FooType, which is an enum with three
values: X,Y,Z.
At the UI level, the Foo instance editing is performed by a details
view. So I prepared a Dto like this:
class FooDto
{
FooDto()
{
FooDtoType = FooType.X.ToString(); //default;
}
string FooDtoType { get; set; }
IEnumerable<string> FooTypeList
{
get
{
return Enum.GetNames(typeof(FooType));
}
}
}
and my DetailsView will be something like:
<aspetailsView ID="fooDetailsView" runat="server">
<asp:TemplateField HeaderText="FooType" InsertVisible="true">
<EditItemTemplate>
<aspropDownList ID="TypeList" runat="server"
DataSource='<%# Eval("FooTypeList") %>'
HeaderText="Tipo" SelectedValue='<%#
Bind("FooDtoType")%>'>
</aspropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<aspropDownList ID="TypeList" runat="server"
DataSource='<%# Eval("FooTypeList") %>'
HeaderText="Tipo" SelectedValue='<%#
Bind("FooDtoType")%>'>
</aspropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Literal ID="FooType" runat="server" Text='<%#
Eval("FooDtoType") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
</aspetailsView>
If I try to edit an existing FooDto (pushing the DetailsView control in
edit mode) everything works fine and in my field I can see a drop down
list filled with all the enum values. If I try to add a new FooDto
(pushing my DetailsView in insert mode) the drop down list is empty
(despite of having boud the control to a new FooDto instance). What's
wrong with my code?
thanks in advance,
Giulio
--