ajaxmethod.cs
来自「这是.net2005学习不可缺少的教程」· CS 代码 · 共 65 行
CS
65 行
using System;
using System.Data;
using System.Data.SqlClient;
namespace WebApplication1
{
/// <summary>
/// Summary description for AjaxMethod.
/// </summary>
public class AjaxMethod
{
#region GetDataSet
public static DataSet GetDataSet(string sql)
{
string ConnectionString=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SqlDataAdapter sda =new SqlDataAdapter(sql,ConnectionString);
DataSet ds=new DataSet();
sda.Fill(ds);
return ds;
}
#endregion
#region GetPovinceList
public static DataSet GetPovinceList()
{
string sql="select * from povince";
return GetDataSet(sql);
}
#endregion
#region GetCityList
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public static string GetCityList(int povinceid)
{
string sql="select * from city where father="+povinceid;
DataSet ds=GetDataSet(sql);
string str="";
for(int m=0;m<ds.Tables[0].Rows.Count;m++)
{
str+=","+ds.Tables[0].Rows[m]["cityID"].ToString()+"|"+ds.Tables[0].Rows[m]["city"].ToString();
}
str=str.Substring(1,str.Length-1);
return str;
}
#endregion
#region GetAreaList
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public static string GetAreaList(int cityid)
{
string sql="select * from area where father="+cityid;
DataSet ds=GetDataSet(sql);
string str="";
for(int m=0;m<ds.Tables[0].Rows.Count;m++)
{
str+=","+ds.Tables[0].Rows[m]["areaID"].ToString()+"|"+ds.Tables[0].Rows[m]["area"].ToString();
}
str=str.Substring(1,str.Length-1);
return str;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?