日期:2014-05-17 浏览次数:20442 次
[AjaxMethod] public DataSet GetData(string UserName) { DataSet ds = new DataSet(); DataTable users= Search.ByUsername(UserName); ds.Tables.Add(users); return ds; }
function showinfo() { var username =$.trim($("#txtUsername").val()); UserManage.UserEdit.GetData(username, function (r) { $("#seluser").empty(); var ds = r.value; if (ds.Tables[0].Rows.length > 0){ $("#Dialoge").show(); var Select = $("#seluser");//id为seluser的select控件 for (var i = 0; i < r.value.Tables[0].Rows.length; i++) { var opt = new Option(ds.Tables[0].Rows[i]["UserName"] , ds.Tables[0].Rows[i]["age"]); Select [0].options.add(opt); } } else { $("#Dialoge").hide(); } }); }
<input id="txtUsername" runat="server" onkeyup="showinfo()" />
function showinfo() { var username =$.trim($("#txtUsername").val()); UserManage.UserEdit.GetData(username, function (r) { if(r.error){alert('动态页出错\n'+r.error.message);return false;}///////// $("#seluser").empty(); var ds = r.value; if (ds.Tables[0].Rows.length > 0){ $("#Dialoge").show(); var Select = $("#seluser");//id为seluser的select控件 for (var i = 0; i < r.value.Tables[0].Rows.length; i++) { var opt = new Option(ds.Tables[0].Rows[i]["UserName"] , ds.Tables[0].Rows[i]["age"]); Select [0].options.add(opt); } } else { $("#Dialoge").hide(); } }); }