无法将下拉框的值,更新到数据库。请帮忙看一下
html:
 <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server">
                        <asp:ListItem>
                        </asp:ListItem>
                        <asp:ListItem>1</asp:ListItem>
                        <asp:ListItem>2</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
 UpdateCommand="UPDATE [bsperson] SET [kb] = @kb, [jz] = @jz,  [xm] = @xm, [jb] = @jb, [zw] = @zw, [rsr] = @rsr, [xb] = @xb, [csnyr] = @csnyr, [lb] = @lb, [dlrq] = @dlrq, [sszz] = @sszz, [ssbz] = @ssbz, [gwm] = @gwm, [gw] = @gw WHERE [gh] = @gh">
cs:
 protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
    {
        if (!IsPostBack)
        {
            for (int i = 0; i < DetailsView1.Rows.Count; i++)
            {
                string ddlstr = string.Empty;
                DropDownList ddl = this.DetailsView1.Rows[i].FindControl("DropDownList1") as DropDownList;
                ddlstr = ddl.SelectedValue.ToString();
             
            }        }   
    }

解决方案 »

  1.   

    DropDownList中你 value值根本就没有设定,
    DropDownList1.items(DropDownList1.selectedindex).Text这样子的 如果你是这样子的话
    <asp:DropDownList ID="DropDownList1" runat="server">
      <asp:ListItem >
      </asp:ListItem>
      <asp:ListItem Value="1">1</asp:ListItem>
      <asp:ListItem Value="2">2</asp:ListItem>
      </asp:DropDownList>  这样就对了
      

  2.   

    楼主还是好好的复习一下控件dropdownlist吧
      

  3.   

    我新增了value的值,还是不行.
    在更新时.ddlstr 的值会等于@xb吗?UpdateCommand="UPDATE [bsperson] SET [kb] = @kb, [jz] = @jz, [xm] = @xm, [jb] = @jb, [zw] = @zw, [rsr] = @rsr, [xb] = @xb, [csnyr] = @csnyr, [lb] = @lb, [dlrq] = @dlrq, [sszz] = @sszz, [ssbz] = @ssbz, [gwm] = @gwm, [gw] = @gw WHERE [gh] = @gh">protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
      {
      if (!IsPostBack)
      {
      for (int i = 0; i < DetailsView1.Rows.Count; i++)
      {
      string ddlstr = string.Empty;
      DropDownList ddl = this.DetailsView1.Rows[i].FindControl("DropDownList1") as DropDownList;
      ddlstr = ddl.SelectedValue.ToString();
        
      }  }   
      }
    求解答.