Gridview中数据绑定Dropdownlist 组件默认值为空null的问题

在gridview中绑定Dropdownlist,遇到过如下错误吗?

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

参数名: value

解决办法:

 <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="LinqDataSource1"
                                            DataTextField="GroupName" DataValueField="itemid" SelectedValue='<%#Bind("Groupname")%>' AppendDataBoundItems=true>
                                            <asp:ListItem Value="">无分组</asp:ListItem>

                                        </asp:DropDownList>

问题关键:AppendDataBoundItems=true和默认值<asp:ListItem Value="">无分组</asp:ListItem>

 

 

 

 

posted on 2008-09-20 19:32  sky老杨  阅读(1475)  评论(0编辑  收藏  举报

导航