报错:DropDownList1”有一个无效 SelectedValue,因为它不在项目列表中

错误:

“DropDownList1”有一个无效 SelectedValue,因为它不在项目列表中。

参数名: value

解决办法:

在下拉框里加一个:<asp:ListItem Value=""> </asp:ListItem>

例如:编辑下拉框时

<asp:TemplateColumn HeaderText="评定等级">
                    <ItemTemplate>
                        <asp:Label ID="Label7" runat="server" Text='<%#Eval("评定等级") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" CssClass="select_n_100" Text='<%#Eval("评定等级") %>'>
                            <asp:ListItem value=""></asp:ListItem>
                            <asp:ListItem Value="红" Text="红"></asp:ListItem>
                            <asp:ListItem Value="橙" Text="橙"></asp:ListItem>
                            <asp:ListItem Value="黄" Text="黄"></asp:ListItem>
                            <asp:ListItem Value="蓝" Text="蓝"></asp:ListItem>
                        </asp:DropDownList>
                        <asp:Label ID="Label6" runat="server" Text='<%#Eval("评定等级") %>'></asp:Label>
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:DropDownList ID="DropDownList2" runat="server" CssClass="select_n_100">
                            <asp:ListItem Value="1">红</asp:ListItem>
                            <asp:ListItem Value="2">橙</asp:ListItem>
                            <asp:ListItem Value="3">黄</asp:ListItem>
                            <asp:ListItem Value="4">蓝</asp:ListItem>
                        </asp:DropDownList>
                         <asp:Label ID="Label8" runat="server" Text='<%#Eval("评定等级") %>'></asp:Label>
                    </FooterTemplate>
</asp:TemplateColumn>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章