开发者

ASP.NEt Dropdown ignores changes

I'm using entity framework and i have a problem that this dropdown ignores my changes / does not reflect db.

 <asp:FormView ID="FormView1" runat="server" DataSourceID="edsFoo" >
 <asp:DropDownList ID="myDD" runat="server" AppendDataBoundItems="true"   DataValueField='<%# Bind("something") %>'>            
 <asp:ListItem Value="0" Text="NO" />
 <asp:ListItem Value="1" Text="YES" />
 <asp:ListItem Value="2" Text="PARTIALLY" />
</asp:DropDownList>
</asp:FormView>

'Something' (in binding) is an int and it's 1. Whe开发者_开发知识库n the form is started, I always see NO, although the value coming from EF is 1. What is wrong please?


Use the 'SelectedValue' property instead of DataValueField. DataValueField is used to specify the property in the datasource to bound for the ListItem value.

<asp:DropDownList ID="myDD" runat="server" AppendDataBoundItems="true"   SelectedValue='<%# Bind("something") %>'>            
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜