我已经将一个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后,你点击更新按钮,它应该更新。 –