0
我需要使用從服務器端方法返回的對象列表填充DropDownList。由於這不應該導致頁面刷新,我正在使用PageMethods。當我調試時,我可以看到正在調用onSuccess函數,但下拉列表沒有被填充。對象列表也成功地從服務器端方法傳遞。我無法找出問題所在。使用PageMethod更新下拉列表
function onsuccess(studList)
{
var ddl = document.getElementById('ddlStud');
var count = ddl.options.length;
while (ddl.options.length > 0)
{
ddl.options.remove(0);
}
for (var i = 0; i < studList.length; i++)
{
var option = document.createElement('<option value="' + studList[i].id + '">');
document.getElementById('ddlStud').options.add(option);
option.innerText = studList[i].StudName;
}
}