我已經將一個DropDownList控件添加到DetailsView中,並且我試圖讓它爲我的更新/插入方法綁定到「狀態」參數。DetailsView中的下拉列表
<InsertItemTemplate>
<asp:DropDownList ID="States" runat="server" SelectedValue='<%# Bind("State") %>'>
<asp:ListItem Value="NY">New York</asp:ListItem>
....
</asp:DropDownList>
</InsertItemTemplate>
我已填充DropDownList中有50個州,所以他們沒有綁定到任何表是靜態的項目。我只想在編輯時選擇一個狀態,當我點擊編輯時,它應該運行存儲過程來編輯並將DropDownList的值作爲@State的參數。
不幸的是,我得到這個錯誤:
'States' has a SelectedValue which is invalid because it does not exist in the
list of items.
Parameter name: value
我研究這個問題,但一些帖子使用,而不是「綁定」或添加一些空值「評估和演示」的建議,但並沒有解決我的問題。你們對我如何才能擺脫這個錯誤有任何想法/建議嗎?
'時,我打edit'你不應該在'EditTemplate'看呢? –
是的,我的意思是當你填入EditTemplate後,你點擊更新按鈕,它應該更新。 –