如何保存dropdownlist中的查询条件,juery已经实现联动。
asp.net mvc2 我已经实现了两个dropdownlist的联动,现在当用dropdownlist中的数据作为查询条件返回后,页面重新刷新了,然后dropdownlist重新填充,之前选择的值不见了,请问改怎么保存更改选择的值呢?
急等!!非常感谢!! 下面是Jquery代码
<script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script language="javascript" type="text/javascript"> function submitFormData() { document.forms[0].submit(); } $(document).ready(function () { GetByJquery(); $("#UserInfo").change(function () { GetRelationShip() }); }); function GetByJquery() { $("#UserInfo").add("--选择--"); var a = Math.random(); var url = "/ExpectedScore/GetUserList/" + "?rand=" + a; $.getJSON(url, function (data) { $.each(data, function (i, item) { $("<option></option>") .val(item["UserId"]) .text(item["UserName"]) }); GetRelationShip(); }); } function GetRelationShip() { $("#RelationShip").empty(); var a = Math.random(); var url = "/ExpectedScore/GetRelationShip/" + $("#UserInfo").val() + "/" + "?rand=" + a; $.getJSON(url, function (data) { $.each(data, function (i, item) { $("<option></option>") .val(item["CustomerId"]) .text(item["CustomerName"]) .appendTo($("#RelationShip")); }); }); } </script>#region 界面还原 ViewBag.OrderState = orderstate; ViewData["Product"] = ProductModels.GetCompanyProduct(UserInfo.CompanyID,0,1); ViewBag.datebegin = datebegin; ViewBag.dateend = dateend; ViewBag.disti_name = disti_name; ViewBag.orderSN = orderSN; ViewBag.click_state = click_state; #endregion
[解决办法]
用dropdownlist中的数据作为查询条件返回后,把dropdownlist中的数据再返回回来不就行了。每次页面刷新的时候,再把这个dropdownlist中的数据用QueryString传回来不行吗?