提示错误
"DropDownList2”有一个无效 SelectedValue,因为它不在项目列表中。
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">
    <ItemTemplate>
        Region:
        <asp:DropDownList ID="DropDownList2" runat="server" 
            DataSourceID="SqlDataSource1" SelectedValue='<%# Bind("Checked") %>'>
            <asp:ListItem Value="0">是</asp:ListItem>
            <asp:ListItem Value="1">否</asp:ListItem>
            <asp:ListItem Value=""></asp:ListItem>
        </asp:DropDownList>
    </ItemTemplate>
</asp:FormView>
SelectedValue绑定的Checked字段在数据表中是有空值的,但是为什么有<asp:ListItem Value=""></asp:ListItem>这样一句也会报错啊,Value=""不表示空值吗?

解决方案 »

  1.   

    ·双线主机 100M/35元/年,免费送数据库(自选MY/MSSQL) 
    ·详情请访问:http://www.515dns.com 
      

  2.   

    建议去掉这句<asp:ListItem Value=""></asp:ListItem>把表中这个字段的默认值设为0或者1.
      

  3.   

    是NULL值吧,与空值不同,一般不能参考操作
      

  4.   

    SelectedValue=null ?  SelectedValue=''   ? 前者好象就是语法错误吧?我也只是猜测
      

  5.   

    以前想这样子写过,跟楼主有相同的问题,可能的原因是所有的代码都同时加载进来(很长的HTML脚本),设置SelectedValue并不能改变DropDownList改变的被选值,SelectedValue应该在DropDownList 加载内容项之后再设置