我有一個具有MailingState
屬性的實體類。我想這樣做的另一個屬性是價值的一些操作,所以我說:如何綁定到我的實體部分類中的自定義屬性
<asp:DropDownList ID="ddlMailingState" runat="server" DataSourceID="ddlAllStates"
AppendDataBoundItems="True" DataTextField="StateAbbreviation"
DataValueField="StateAbbreviation"
SelectedValue='<%# Bind("MailingStateAbbreviation") %>'>
<asp:ListItem Value="" Text="" />
</asp:DropDownList>
:
public string MailingStateAbbreviation
{
get { return getStateAbbreviation(MailingState); }
set { MailingState = value; }
}
然而,在DetailsView
EditItemTemplate
,下面當我嘗試提交編輯表格失敗如果我改變Bind
到Eval
在SelectedValue
,形式submi
A property named 'MailingStateAbbreviation' was not found on the entity during an insert, update, or delete operation. Check to ensure that properties specified as binding expressions are available to the data source.
:我得到這個錯誤ts罰款,但MailingState
屬性不更新。我怎樣才能將表單控件綁定到我的實體上的自定義屬性?