<ItemTemplate>
                        <asp:DropDownList ID="DDLDepotCategory" runat="server" 
                            DataSourceID="SqlDataSource1" DataTextField="DepotCategory" 
                            DataValueField="DepotCategory" 
                            SelectedValue='<%# DataBinder.Eval(Container.DataItem,"DepotCategory") %>'>
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ETHANConnectionString %>" 
                            SelectCommand="SELECT [DepotCategory] FROM [DepotCategory]">
                        </asp:SqlDataSource>
                    </ItemTemplate>protected void RawDataBind()
    {
        if (!IsPostBack)
        {
            dt.Columns.Add("DepotCategory");
            dt.Columns.Add("Notes");
            for (int i = 0; i < 3; i++)
            {
                DataRow dr = dt.NewRow();
                dt.Rows.Add(dr);
            }
            this.GVStorage.DataSource = dt;
            this.GVStorage.DataBind();
        }
    }代码是一样的  在test里写好了  复制到其他页面上
就出现
“DDLDepotCategory”有一个无效 SelectedValue,因为它不在项目列表中。
参数名: value后来干脆重新绑定 datasource  还是一样!!

解决方案 »

  1.   

    加 DDLDepotCategory.Items.Clear();
      

  2.   

    SelectedValue,
    自己动手在客户端,或者是服务段实现一下吧。
      

  3.   

    gridview  不支持直接引用DDLDepotCategory噢
      

  4.   

    数据库多了 空行,已经解决了噢能不能 在sqldatasource绑定之后 在头行加一个    请选择呢
      

  5.   

     DropDownList1.Items.Insert(0, new ListItem("请选择", "0"));