0
我正在爲一個學校項目做這個網站,當我運行這個網站時我有一個GridView,我選擇一個註冊表,然後它打開FormView,並顯示關於所選註冊表的所有細節DropDownList有一個無效的SelectedValue錯誤
現在,當我打的編輯在FormView控件它給了我下面的錯誤: 「ddl_SelectMae」有一個無效的SelectedValue,因爲它不在項目列表中存在。參數名:價值
我知道,出現此錯誤,因爲現場「美」的值是空的,但我看到了數據庫和值可以爲null。 (同樣的錯誤適用於「排」和「買辦」字段)
在這些地方發生錯誤代碼的一部分,如果需要的話
<asp:FormView ID="fv_Alteracoes" runat="server" DataKeyNames="idCao" DataSourceID="SqlDS_InsEdiDel">
<EditItemTemplate>
<table>
<tr>
<td>Mãe:</td>
<td>
<asp:DropDownList ID="dll_SelectMae" runat="server" DataSourceID="SqlDS_ListarMae" DataTextField="idCao" DataValueField="idCao"
SelectedValue='<%# Bind("Mae") %>'>
</asp:DropDownList>
<asp:SqlDataSource runat="server" ID="SqlDS_ListarMae" ConnectionString='<%$ ConnectionStrings:ConnectionString %>'
SelectCommand="SELECT [idCao], [Nome] FROM [tbl_Cao] WHERE ([Sexo] = 'F')">
</asp:SqlDataSource>
</td>
</table>
<asp:LinkButton runat="server" Text="Update" CommandName="Update" ID="UpdateButton" CausesValidation="True" />
<asp:LinkButton runat="server" Text="Cancel" CommandName="Cancel" ID="UpdateCancelButton" CausesValidation="False" />
</EditItemTemplate>
如果我這樣做,我可以把所有的代碼相同的,但與所有的細節註冊表填補了網站的工作100%,因爲我想
Image of website working perfectly
有人可以幫助我如何停止的錯誤,並保持DropDownLis t編輯字段?
PS:很抱歉,我的英語,但我是葡萄牙人,感謝你的幫助