日期:2014-05-17  浏览次数:20826 次

在javascript方法中如何取得页面中DropDownList选中的值???
protected void Page_Load(object sender, EventArgs e)
  {
  if (!IsPostBack)
  {
  this.DropDownList1.DataSource = new PartManager().GetAll();
  this.DropDownList1.DataTextField = "PartName";
  this.DropDownList1.DataValueField = "Id";
  this.DropDownList1.DataBind();
   
  }
  }

页面中绑定DropDownList。

<script language="javascript" type="text/javascript" >
  function mytest2() {
  var part = null;
  var dropdownlist = document.getElementById("DropDownList1");
</script>
想取得选中项的DataValueField接着怎么写???

------解决方案--------------------
dropdownlist.options[dropdownlist.selectedIndex].value;
试试