关于DropDownList

1、c#中对于dropdownlist1值的读取

查询文本值:dropdownlist1.SelectedItem.Text
列表值:dropdownlist1.SelectedValue

2、在js脚本中查询dropdownlist的文本值:

var items = document.getElementById("DropDownList1");

var varValue=items.options[items.selectedIndex].innerText;

在js脚本中查询dropdownlist的列表值:

 var a = $("select[@dropdownlist1:items] option[@selected]".value);

3、将数据循环遍历到下拉列表如何添加值(以学科id及name为例):
                for (var i = 0; i < json.length; i++) {
                                 $("#<%=dropdownlist1.ClientID %>").append('<option value=' + json[i].subjectId + '>' + json[i].subjectName + '</option>');
               }  

posted @ 2013-03-18 11:01  淡淡的抹抹忧伤  阅读(178)  评论(0编辑  收藏  举报