我从表中取出分类记录,然后邦定到DropDownlist,怎么获得DropDownlist选择分类的ID呢 

解决方案 »

  1.   

    邦定时:DropDownlist.DataValueField = "id";取值:DropDownlist.SelectedValue;
      

  2.   

    DropDownlist.DataSource = ds;
    DropDownlist.TextValueField = "name";
    DropDownlist.DataValueField = "id";
    DropDownlist.DataBind();
      

  3.   

    DropDownlist.DataSource = ds;
    DropDownlist.TextValueField = "name";
    DropDownlist.DataValueField = "id";
    DropDownlist.DataBind();取值:
    DropDownlist.SelectedValue;
      

  4.   

    da.Fill(ds, "category")
            ddl.DataSource = ds.Tables("category").DefaultView
            ddl.DataTextField = "CategoryName"
            ddl.DataBind() comm.Parameters.Add("@catename", OleDbType.VarChar, 200)
                    comm.Parameters("@catename").Value = ddl.SelectedValue