日期:2014-05-17 浏览次数:20574 次
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ajaxtest.aspx.cs" Inherits="ajaxtest" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>AjaxPro-DropDownList无刷新联动</title> <script language="javascript" type="text/javascript"> function GetTeamList() { var System=document.getElementById("SystemList"); ajaxtest.TeamName(System.value,TeamCallBack); } function TeamCallBack pub
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class ajaxtest : System.Web.UI.Page { pub b = new pub(); protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(ajaxtest)); if (!Page.IsPostBack) { SystemName(); TeamList.DataSource = TeamName(SystemList.SelectedValue.Trim()); TeamList.DataTextField = "mc"; TeamList.DataValueField = "mc"; TeamList.DataBind(); SystemList.Attributes.Add("onchange", "GetTeamList();"); } } private void SystemName() { try { DataSet ds = b.GetDataSet("select mc from city where lx=1", "cspq"); SystemList.DataSource =ds.Tables[0]; SystemList.DataTextField = "mc"; SystemList.DataValueField = "mc"; SystemList.DataBind(); } catch { } } [AjaxPro.AjaxMethod] /**//// <summary> /// ajax调用方法 /// </summary> /// <param name="systemselectname"></param> public DataTable TeamName(string systemselectname) { try { DataSet ds2 = b.GetDataSet("select mc from city where lx=2 and sjbh in (select id from city where lx=1 and mc='" + systemselectname + "')", "cspq2"); return ds2.Tables[0]; } catch { return null; } } }