0
您好,我已将一些项目添加到来自javascript的asp:DropDownList
。像这样获取从javascript中添加的dropdownlist项的selectedvalue
if (document.getElementById("<%=gdview.ClientID %>")!=null)
{
var rows = document.getElementById("<%=gdview.ClientID %>").getElementsByTagName('tr');
var cells = rows[1].getElementsByTagName('td');
//alert(cells)
i = 2;
while (i < cells.length)
{
document.getElementById("<%=ddl_noofCols.ClientID %>").options[i] = new Option(i + 1, i);
i++;
}
document.getElementById("<%=ddl_noofCols.ClientID %>").options[2].selected =true;
alert(document.getElementById("<%=ddl_noofCols.ClientID %>").options[2].text);
}
这里gdview是gridview。没有任何gridview列被添加到下拉列表 默认为options[2]
被选中。我不能使用返回null的ddl_noofCols.SelectedValue
获取selecteditem/selectedvalue。
如何获取selectedvalue。
在此先感谢。
我想将选择值我提到的代码隐藏为'ddl_noofCols.SelectedValue' – Nag 2012-08-06 06:36:42