我在使用Jquery的客戶端綁定下拉菜單。我使用PageMethods從服務器獲取數據。如何在回發後保留下拉數據
HTML
<asp:DropDownList ID="ddlCountry" runat="server" ClientIDMode="Static"
onchange="return country_changed();" ViewStateMode="Enabled">
</asp:DropDownList>
JS
function GetCountryLst() {
PageMethods.GetCountryList(OnsuccessCountry);
return false;
}
function OnsuccessCountry(result) {
$("#ddlCountry").append("<option value='Select'>Select</option>");
for (var eachval in result) {
$("#ddlCountry").append("<option value='" + result[eachval].id + "'>" + result[eachval].name + "</option>");
}
return false;
}
,當我寫
protected void Button2_Click(object sender, EventArgs e)
{
var ddlcount = ddlCountry.Items.Count;
}
按鈕點擊我得到ddlCount = 0;我如何保存數據
[Rü使用更新面板? – Marwan 2011-05-18 11:12:49
不,我沒有使用updatepanel。但是,我不介意使用它,如果我得到的值在服務器端 – Tuscan 2011-05-18 11:21:06
你只想計數或所有的值也? – 2011-05-18 11:21:32