druiddatasourceeSelectArguments 是什么属性

vfp中列表框的rowsourcetype属性是什么意思?_百度知道
vfp中列表框的rowsourcetype属性是什么意思?
提问者采纳
表示数据来源的类型,比如:表、查询、数组等。
其他类似问题
列表框的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁DataReader包含一行或多行数据的属性是什么?_百度知道
DataReader包含一行或多行数据的属性是什么?
A FileCountB RowsCountC HasRowsD IsMore
为什么啊 ?
提问者采纳
B 行数 datareader.rowscount返回的是记录的行数,比如有5行记录,就是5,所以是这5行记录的属性阿
提问者评价
先谢谢你。但是答案不对。是C。谢谢
其他类似问题
datareader的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁ObjectDataSource.UpdateMethod 属性 (System.Web.UI.WebControls)
ObjectDataSource.UpdateMethod 属性
.NET Framework 2.0
注意:此属性在 .NET Framework 2.0 版中是新增的。
获取或设置由
控件调用以更新数据的方法或函数的名称。
命名空间:System.Web.UI.WebControls程序集:System.Web(在 system.web.dll 中)
public string UpdateMethod { get; set; }
/** @property */
public String get_UpdateMethod ()
/** @property */
public void set_UpdateMethod (String value)
public function get UpdateMethod () : String
public function set UpdateMethod (value : String)
一个字符串,表示由 ObjectDataSource 用来更新数据的方法或函数的名称。默认为空字符串。
ObjectDataSource 控件假定 UpdateMethod 属性标识的方法按逐个(而不是以批处理)的方式执行更新。
UpdateMethod 属性委托给与 ObjectDataSource 控件关联的
由 UpdateMethod 属性标识的方法可能是一个实例方法或一个 static(在 Visual Basic 中为 Shared)方法。如果它是实例方法,则在每次调用由 UpdateMethod 属性指定的时都会创建并销毁业务对象。您可以处理
事件,在调用 UpdateMethod 属性指定的方法前使用业务对象。还可以处理在调用 UpdateMethod 属性指定的方法后引发的
事件。如果业务对象实现
接口,则在销毁该对象前调用
方法。如果方法是 static(在 Visual Basic 中为 Shared)方法,则从不创建业务对象,而且您无法处理 ObjectCreated、ObjectCreating 和 ObjectDisposing 事件。
参数从三个来源添加到
从数据绑定控件(在运行时)。
从 UpdateParameters 元素(以声明方式)。
事件处理程序(以编程方式)。
首先,将通过数据绑定控件生成的任何参数添加到
集合中。例如,如果 ObjectDataSource 控件绑定到具有列 Name 和 Number 的
控件,则将 Name 和 Number 的参数添加到集合中。参数的确切名称取决于
属性。这些参数的数据类型是 string。然后,添加 UpdateParameters 元素中列出的参数。如果在 UpdateParameters 元素中找到与 UpdateParameters 集合中的现有参数同名的参数,则修改现有参数以匹配 UpdateParameters 元素中指定的参数。这通常用于修改参数中的数据类型。最后,可以以编程方式添加和移除 Updating 事件中的参数,该事件在
方法运行前发生。合并参数后解析方法。下一节讨论方法解析。
调用 Update 方法时,数据绑定控件中的数据字段、UpdateParameters 元素中以声明方式创建的参数和 Updating 事件处理程序中添加的参数全部合并在一起。(有关更多信息,请参见上一节。)ObjectDataSource 控件尝试查找可以调用的方法。首先,它查找具有 UpdateMethod 属性中指定的名称的一个或多个方法。如果没有找到匹配项,则引发
异常。如果找到了匹配项,它随后将查找匹配的参数名。例如,假定
属性指定的类型有两个名为 UpdateARecord 的方法。一个 UpdateARecord 带一个参数 ID,而另一个 UpdateARecord 带两个参数 Name 和 Number。如果 UpdateParameters 集合只包含一个名为 ID 的参数,则调用仅带 ID 参数的 UpdateARecord 方法。解析方法时不检查参数类型。参数的顺序无关紧要。
如果设置了
属性,将以不同的方式解析方法。ObjectDataSource 查找具有 UpdateMethod 属性中指定的名称的方法,该属性带 DataObjectTypeName 属性中指定的类型的一个参数。这种情况下,参数的名称无关紧要。
本节包含两个代码示例。第一个代码示例演示如何使用
控件、 控件和若干个 ObjectDataSource 对象来更新数据。第二个代码示例演示在第一个代码示例中使用的 EmployeeLogic 类。 下面的代码示例演示如何使用 DropDownList 控件、TextBox 控件和多个 ObjectDataSource 控件更新数据。DropDownList 显示 Northwind 雇员的名称,而 TextBox 控件用于输入和更新地址信息。由于 UpdateParameters 集合包含绑定到 DropDownList 的选定值的
对象,因此只有在选中一个雇员后才会启用引发 Update 操作的按钮。
&%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS" Assembly="Samples.AspNet.CS" %&
&%@ Page language="c#" %&
&%@ Import namespace="Samples.AspNet.CS" %&
&Script runat="server"&
// Add parameters and initialize the user interface
// only if an employee is selected.
private void Page_Load(object sender, EventArgs e)
// Be sure the text boxes are initialized with
// data from the currently selected employee.
NorthwindEmployee selectedEmployee = EmployeeLogic.GetEmployee(DropDownList1.SelectedValue);
if (selectedEmployee != null) {
AddressBox.Text
= selectedEmployee.A
CityBox.Text
= selectedEmployee.C
PostalCodeBox.Text = selectedEmployee.PostalC
Button1.Enabled = true;
Button1.Enabled = false;
// Press the button to update.
private void Btn_UpdateEmployee (object sender, CommandEventArgs e) {
ObjectDataSource2.Update();
&title&ObjectDataSource - C# Example&/title&
&form id="Form1" method="post" runat="server"&
&!-- The DropDownList is bound to the first ObjectDataSource. --&
&asp:objectdatasource
id="ObjectDataSource1"
runat="server"
selectmethod="GetAllEmployees"
typename="Samples.AspNet.CS.EmployeeLogic" /&
&p&&asp:dropdownlist
id="DropDownList1"
runat="server"
datasourceid="ObjectDataSource1"
datatextfield="FullName"
datavaluefield="EmpID"
autopostback="True" /&&/p&
&!-- The second ObjectDataSource performs the Update. This
preserves the state of the DropDownList, which otherwise
would rebind when the DataSourceChanged event is
raised as a result of an Update operation. --&
&!-- Security Note: The ObjectDataSource uses a FormParameter,
Security Note: which does not perform validation of input from the client.
Security Note: To validate the value of the FormParameter,
Security Note: handle the Updating event. --&
&asp:objectdatasource
id="ObjectDataSource2"
runat="server"
updatemethod="UpdateEmployeeWrapper"
typename="Samples.AspNet.CS.EmployeeLogic"&
&updateparameters&
&asp:controlparameter name="anID" controlid="DropDownList1" propertyname="SelectedValue" /&
&asp:formparameter name="anAddress" formfield="AddressBox" /&
&asp:formparameter name="aCity" formfield="CityBox" /&
&asp:formparameter name="aPostalCode" formfield="PostalCodeBox" /&
&/updateparameters&
&/asp:objectdatasource&
&p&&asp:textbox
id="AddressBox"
runat="server" /&&/p&
&p&&asp:textbox
id="CityBox"
runat="server" /&&/p&
&p&&asp:textbox
id="PostalCodeBox"
runat="server" /&&/p&
&asp:button
id="Button1"
runat="server"
text="Update Employee"
oncommand="Btn_UpdateEmployee" /&
&%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL" Assembly="Samples.AspNet.JSL" %&
&%@ Page language="VJ#" %&
&%@ Import namespace="Samples.AspNet.JSL" %&
&Script runat="server"&
// Add parameters and initialize the user interface
// only if an employee is selected.
private void Page_Load(Object sender, EventArgs e) throws NorthwindDataException
// Be sure the text boxes are initialized with
// data from the currently selected employee.
NorthwindEmployee selectedEmployee =
EmployeeLogic.GetEmployee(DropDownList1.get_SelectedValue());
if (selectedEmployee != null) {
AddressBox.set_Text(selectedEmployee.get_Address());
CityBox.set_Text(selectedEmployee.get_City());
PostalCodeBox.set_Text(selectedEmployee.get_PostalCode());
Button1.set_Enabled(true);
Button1.set_Enabled(false);
} //Page_Load
// Press the button to update.
private void Btn_UpdateEmployee(Object sender, CommandEventArgs e)
ObjectDataSource2.Update();
} //Btn_UpdateEmployee
&title&ObjectDataSource - VJ# Example&/title&
&form id="Form1" method="post" runat="server"&
&!-- The DropDownList is bound to the first ObjectDataSource. --&
&asp:objectdatasource
id="ObjectDataSource1"
runat="server"
selectmethod="GetAllEmployees"
typename="Samples.AspNet.JSL.EmployeeLogic" /&
&p&&asp:dropdownlist
id="DropDownList1"
runat="server"
datasourceid="ObjectDataSource1"
datatextfield="FullName"
datavaluefield="EmpID"
autopostback="True" /&&/p&
&!-- The second ObjectDataSource performs the Update. This
preserves the state of the DropDownList, which otherwise
would rebind when the DataSourceChanged event is
raised as a result of an Update operation. --&
&asp:objectdatasource
id="ObjectDataSource2"
runat="server"
updatemethod="UpdateEmployeeWrapper"
typename="Samples.AspNet.JSL.EmployeeLogic"&
&updateparameters&
&asp:controlparameter name="anID" controlid="DropDownList1" propertyname="SelectedValue" /&
&asp:formparameter name="anAddress" formfield="AddressBox" /&
&asp:formparameter name="aCity" formfield="CityBox" /&
&asp:formparameter name="aPostalCode" formfield="PostalCodeBox" /&
&/updateparameters&
&/asp:objectdatasource&
&p&&asp:textbox
id="AddressBox"
runat="server" /&&/p&
&p&&asp:textbox
id="CityBox"
runat="server" /&&/p&
&p&&asp:textbox
id="PostalCodeBox"
runat="server" /&&/p&
&asp:button
id="Button1"
runat="server"
text="Update Employee"
oncommand="Btn_UpdateEmployee" /&
下面的代码示例显示了前面的代码示例中使用的 EmployeeLogic 类。
namespace Samples.AspNet.CS {
using System.C
using System.C
using System.D
using System.Data.SqlC
using System.Web.UI;
using System.Web.UI.WebC
// EmployeeLogic is a stateless business object that encapsulates
// the operations one can perform on a NorthwindEmployee object.
public class EmployeeLogic {
// Returns a collection of NorthwindEmployee objects.
public static ICollection GetAllEmployees () {
ArrayList al = new ArrayList();
// Use the SqlDataSource class to wrap the
// ADO.NET code required to query the database.
ConnectionStringSettings cts = ConfigurationManager.ConnectionStrings["NorthwindConnection"];
SqlDataSource sds
= new SqlDataSource(cts.ConnectionString,
"SELECT EmployeeID FROM Employees");
IEnumerable IDs = sds.Select(DataSourceSelectArguments.Empty);
// Iterate through the Enumeration and create a
// NorthwindEmployee object for each ID.
IEnumerator enumerator = IDs.GetEnumerator();
while (enumerator.MoveNext()) {
// The IEnumerable contains DataRowView objects.
DataRowView row = enumerator.Current as DataRowV
string id = row["EmployeeID"].ToString();
NorthwindEmployee nwe = new NorthwindEmployee(id);
// Add the NorthwindEmployee object to the collection.
al.Add(nwe);
// If anything strange happens, clean up.
sds.Dispose();
public static NorthwindEmployee GetEmployee(object anID) {
ArrayList al = GetAllEmployees() as ArrayL
IEnumerator enumerator = al.GetEnumerator();
while (enumerator.MoveNext()) {
// The IEnumerable contains initialized NorthwindEmployee objects.
NorthwindEmployee ne = enumerator.Current as NorthwindE
if (ne.EmpID.Equals(anID.ToString())) {
return null;
public static void UpdateEmployee(NorthwindEmployee ne) {
bool retval = ne.Update();
if (! retval) { throw new NorthwindDataException("Employee update failed."); }
// This method is added as a conveniece wrapper on the original
// implementation.
public static void UpdateEmployeeWrapper(string anID,
string anAddress,
string aCity,
string aPostalCode) {
NorthwindEmployee ne = new NorthwindEmployee(anID);
ne.Address = anA
ne.City = aC
ne.PostalCode = aPostalC
UpdateEmployee(ne);
// And so on...
public class NorthwindEmployee {
public NorthwindEmployee (object anID) {
this.ID = anID;
ConnectionStringSettings cts = ConfigurationManager.ConnectionStrings["NorthwindConnection"];
SqlConnection conn = new SqlConnection (cts.ConnectionString);
SqlCommand sc =
new SqlCommand(" SELECT FirstName,LastName,Address,City,PostalCode " +
" FROM Employees " +
" WHERE EmployeeID = @empId",
// Add the employee ID parameter and set its value.
sc.Parameters.Add(new SqlParameter("@empId",SqlDbType.Int)).Value = Int32.Parse(anID.ToString());
SqlDataReader sdr = null;
conn.Open();
sdr = sc.ExecuteReader();
// This is not a while loop. It only loops once.
if (sdr != null && sdr.Read()) {
// The IEnumerable contains DataRowView objects.
this.firstName
= sdr["FirstName"].ToString();
this.lastName
= sdr["LastName"].ToString();
this.address
= sdr["Address"].ToString();
= sdr["City"].ToString();
this.postalCode
= sdr["PostalCode"].ToString();
throw new NorthwindDataException("Data not loaded for employee id.");
if (sdr != null) sdr.Close();
conn.Close();
catch (SqlException) {
// Log an event in the Application Event Log.
private object ID;
public object EmpID {
get { return ID; }
private string lastN
public string LastName {
set { lastName = }
private string firstN
public string FirstName {
set { firstName =
public string FullName {
get { return firstName + " " + lastN }
private string
public string Address {
get { return }
set { address =
private string
public string City {
get { return }
set { city =
private string postalC
public string PostalCode {
get { return postalC }
set { postalCode =
public bool Update () {
// Implement Update logic.
return true;
internal class NorthwindDataException: Exception {
public NorthwindDataException(string msg) : base (msg) { }
package Samples.AspNet.JSL;
import System.*;
import System.Collections.*;
import System.Configuration.*;
import System.Data.*;
import System.Data.SqlClient.*;
import System.Web.UI.*;
import System.Web.UI.WebControls.*;
// EmployeeLogic is a stateless business object that encapsulates
// the operations one can perform on a NorthwindEmployee object.
public class EmployeeLogic
// Returns a collection of NorthwindEmployee objects.
public static ICollection GetAllEmployees() throws NorthwindDataException
ArrayList al = new ArrayList();
// Use the SqlDataSource class to wrap the
// ADO.NET code required to query the database.
ConnectionStringSettings cts =
ConfigurationManager.get_ConnectionStrings().
get_Item("NorthwindConnection");
SqlDataSource sds = new SqlDataSource(cts.get_ConnectionString(),
"SELECT EmployeeID FROM Employees");
IEnumerable ids = sds.Select(DataSourceSelectArguments.get_Empty());
// Iterate through the Enumeration and create a
// NorthwindEmployee object for each ID.
IEnumerator enumerator = ids.GetEnumerator();
while (enumerator.MoveNext()) {
// The IEnumerable contains DataRowView objects.
DataRowView row = (DataRowView)enumerator.get_Current();
String idObj = row.get_Item("EmployeeID").ToString();
NorthwindEmployee nwe = new NorthwindEmployee(idObj);
// Add the NorthwindEmployee object to the collection.
al.Add(nwe);
// If anything strange happens, clean up.
sds.Dispose();
} //GetAllEmployees
public static NorthwindEmployee GetEmployee(Object anID)
throws NorthwindDataException
ArrayList al = (ArrayList)GetAllEmployees();
IEnumerator enumerator = al.GetEnumerator();
while (enumerator.MoveNext()) {
// The IEnumerable contains initialized NorthwindEmployee objects.
NorthwindEmployee ne = (NorthwindEmployee)enumerator.get_Current();
if (ne.get_EmpID().Equals(anID.ToString())) {
} //GetEmployee
public static void UpdateEmployee(NorthwindEmployee ne)
throws NorthwindDataException
boolean retVal = ne.Update();
if (!(retVal)) {
throw new NorthwindDataException("Employee update failed.");
} //UpdateEmployee
// This method is added as a conveniece wrapper on the original
// implementation.
public static void UpdateEmployeeWrapper(String anID, String anAddress,
String aCity, String aPostalCode) throws NorthwindDataException
NorthwindEmployee ne = new NorthwindEmployee(anID);
ne.set_Address(anAddress);
ne.set_City(aCity);
ne.set_PostalCode(aPostalCode);
UpdateEmployee(ne);
} //UpdateEmployeeWrapper
// And so on...
} //EmployeeLogic
public class NorthwindEmployee
public NorthwindEmployee(Object anID) throws NorthwindDataException
this.id = anID;
ConnectionStringSettings cts =
ConfigurationManager.get_ConnectionStrings().
get_Item("NorthwindConnection");
SqlConnection conn = new SqlConnection(cts.get_ConnectionString());
SqlCommand sc = new SqlCommand(" SELECT FirstName,LastName,Address,"
+ "City,PostalCode " + " FROM Employees "
+ " WHERE EmployeeID = @empId", conn);
// Add the employee ID parameter and set its value.
sc.get_Parameters().Add(new SqlParameter("@empId", SqlDbType.Int)).
set_Value(anID.ToString());
SqlDataReader sdr =
conn.Open();
sdr = sc.ExecuteReader();
// This is not a while loop. It only loops once.
if (sdr != null && sdr.Read()) {
// The IEnumerable contains DataRowView objects.
this.firstName = sdr.get_Item("FirstName").ToString();
this.lastName = sdr.get_Item("LastName").ToString();
this.address = sdr.get_Item("Address").ToString();
this.city = sdr.get_Item("City").ToString();
this.postalCode = sdr.get_Item("PostalCode").ToString();
throw new NorthwindDataException("Data not loaded for"
+ " employee id.");
if (sdr != null) {
sdr.Close();
conn.Close();
catch (SqlException exp) {
// Log an event in the Application Event Log.
} //NorthwindEmployee
/** @property
public Object get_EmpID()
} //get_EmpID
private String lastN
/** @property
public void set_LastName(String value)
lastName =
} //set_LastName
private String firstN
/** @property
public void set_FirstName(String value)
firstName =
} //set_FirstName
/** @property
public String get_FullName()
return firstName + " " + lastN
} //get_FullName
/** @property
public String get_Address()
} //get_Address
/** @property
public void set_Address(String value)
} //set_Address
/** @property
public String get_City()
} //get_City
/** @property
public void set_City(String value)
} //set_City
private String postalC
/** @property
public String get_PostalCode()
return postalC
} //get_PostalCode
/** @property
public void set_PostalCode(String value)
postalCode =
} //set_PostalCode
public boolean Update()
// Implement Update logic.
} //Update
} //NorthwindEmployee
public class NorthwindDataException extends Exception
public NorthwindDataException(String msg)
super(msg);
} //NorthwindDataException
} //NorthwindDataException
Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见。受以下版本支持:2.0
您对此内容的反馈非常重要。请告诉我们您的想法。
更多反馈?
1500 个剩余字符
我们非常感谢您的反馈。
开发人员中心博客原文:
源码下载:
&&&& QQ个人资料
淘宝网会员资料
在IT发展日渐成熟的今天,软件作为IT产品中的灵魂已经起到了不可磨灭的作用,准确的说没有了软件,基本上所有的智能电子产品都是废品,比如最为常见的电脑、MP4、手机、数码相机等等。自从1985年微软推出第一款Windows操作系统Windows 1.0之后,窗口应用式操作软件也得到了飞速的发展。而在当今,各样的开发语言,操作系统,开发环境也是层出不穷,不断地新老更替,这也就带了一个不小的问题,即如何做到一个应用软件的跨平台跨语言跨机器的问题,也就是程序与程序,程序与宿主之间的兼容性问题。随着网络的发展,基于B/S(Browser/Server)结构的应用软件也就是我们通常说的网站,因其能很好的解决软件的跨平台跨语言跨机器的问题而得到了很好的发展和应用,无论该软件是通过何种技术或语言进行开发的,他只需要将用户请求需要的相应的内容转换成HTML代码(也包括常用的JavaScript脚本)发送到客户端浏览器,这样既解决了兼容性问题,也极大地减少了软件维护的成本。
基于浏览器/服务器结构的应用软件得到了发展,自然各种浏览器也就会应运而生,比如在我国用的最多的IE、火狐、遨游、世界之窗以及刚冒出来不久的360、腾讯TT等等,其实浏览器的功能都大同小异,都是通过解析HTML代码以满足用户需求,只是使用的习惯略有区别而已,既然有小异,那肯定在某些问题的处理上还是有区别的,在即将讨论的这个问题中我们就会遇到。
来说本次讨论的主题,AJAX(Asynchronous JavaScript And XML,异步JavaScript和XML),是2005 年由Google推广开来的一种编程模式。AJAX不是一种新的编程语言,而是一种使用现有标准的新方法,通过基于JavaScript和HTTP请求的AJAX,可以创建更好、更快以及更友好的WEB应用程序,他最大的特点就是无刷新,速度快。AJAX的核心就是集成于JavaScript中的XMLHttpRequest对象,他能通过异步的方式与服务器间进行数据交互,常用的属性和方法有:
xmlhttp.onreadystatechange = LoadP //设置当其请求状态改变时调用的方法
xmlhttp.open(&GET&, &DealRequestServices.ashx?requesttypeid=1&, true); //设置其请求的方式、地址、是否异步
xmlhttp.send(null); //发送请求
xmlhttp.readyState == 4
xmlhttp.status == 200
xmlhttp.responseText //从服务器返回的字符串
对象XMLHttpRequest属性readyState的含义:
0——(未初始化)send方法还没有被调用
1——(加载中)已调用了send方法,请求还在处理
2——(已加载)send方法已完成,整个应答已接收
3——(交互中)正在解析应答
4——(已完成)应答已经解析,准备好进行下一步处理。
对象XMLHttpRequest属性status的含义:
100——客户必须继续发出请求(Continue)
101——客户要求服务器根据请求转换HTTP协议版本(Switching protocols)
200——交易成功(OK)
201——提示知道新文件的URL(Created)
202——接受和处理、但处理未完成(Accepted)
203——返回信息不确定或不完整(Non-Authoritative Information)
204——请求收到,但返回信息为空(No Content)
205——服务器完成了请求,用户代理必须复位当前已经浏览过的文件(Reset Content)
206——服务器已经完成了部分用户的GET请求(Partial Content)
300——请求的资源可在多处得到(Multiple Choices)
301——删除请求数据(Moved Permanently)
302——在其他地址发现了请求数据(Found)
303——建议客户访问其他URL或访问方式(See Other)
304——客户端已经执行了GET,但文件未变化(Not Modified)
305——请求的资源必须从服务器指定的地址得到(Use Proxy)
306——前一版本HTTP中使用的代码,现行版本中不再使用
307——申明请求的资源临时性删除(Temporary Redirect)
400——错误请求,如语法错误(Bad Request)
401——请求授权失败(Unauthorized)
402——保留有效ChargeTo头响应(Payment Required)
403——请求不允许(由于服务器上文件或目录的权限设置导致资源不可用)(Forbidden)
404——没有发现文件、查询或URl(没有找到指定的资源)(Not Found)
405——用户在Request-Line字段定义的方法不允许(Method Not Allowed)
406——根据用户发送的Accept拖,请求资源不可访问(Not Acceptable)
407——类&#,用户必须首先在代理服务器上得到授权(Proxy Authentication Required)
408——客户端没有在用户指定的饿时间内完成请求(Request Timeout)
409——对当前资源状态,请求不能完成(Conflict)
410——服务器上不再有此资源且无进一步的参考地址(Gone)
411——服务器拒绝用户定义的Content-Length属性请求(Length Required)
412——一个或多个请求头字段在当前请求中错误(Precondition Failed)
413——请求的资源大于服务器允许的大小(Request Entity Too Large)
414——请求的资源URL长于服务器允许的长度(Request-URI Too Long)
415——请求资源不支持请求项目格式(Unsupported Media Type)
416——请求中包含Range请求头字段,在当前请求资源范围内没有range指示值,请求也不包含If-Range请求头字段(Requested Range Not Suitable)
417——服务器不满足请求Expect头字段指定的期望值,如果是代理服务器,可能是下一级服务器不能满足请求(Expectation Failed)
500——服务器产生内部错误(Internal Server Error)
501——服务器不支持请求的函数(Not Implemented)
502——服务器暂时不可用,有时是为了防止发生系统过载(Bad Gateway)
503——服务器过载或暂停维修(Service Unavailable)
504——关口过载,服务器使用另一个关口或服务来响应用户,等待时间设定值较长(Gateway Timeout)
505——服务器不支持或拒绝支请求头中指定的HTTP版本(HTTP Version Not Supported )
12029——网络不通. 刷新一下就知道了
省市县下拉列表框三级联动在各种网页中使用的非常普遍,由于QQ软件是C/S(Client/Server)结构的,所以可以肯定的说在上图中的QQ个人资料修改绝对和AJAX没有任何关系,当然若是在网页中修改那就不一样了。有些网站中的三级联动是把全国34个省345个市3144个县全部写在数组里,然后通过JAVASCRIPT来动态变动,这是一种蠢到家的做法,这里完全可以通过AJAX,在页面加载完毕时先把所有的省从服务器请求下来然后加载到省的下拉列表框,然后在省的下拉列表框改动时再从服务器把该省对应下的所有市请求下来加载到市的下拉列表框,再在市的下拉列表框改动时从服务器把该市对应下的所有县请求下来加载到县的下拉列表框。
诚然,有客户端请求,对应着就得有服务器的处理,在服务器端通过客户端请求的时传过来的类别和参数进行相应的判断,然后再从数据库中查询出结果集排列成指定的字符串,发送给客户端,在客户端来解析这段字符串然后加载到下拉列表框。具体示例中包含两个文件,一个是XMLHttpRequest.html,另一个是DealRequestServices.ashx,这是一个中间处理程序文件,他和普通的页面差文件不多,只是没有源码只有后台代码,XMLHttpRequest.html文件类容如下:
&!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&&
&&& &title&AJAX省市县三级联动之XMLHttpRequest&/title&
&&& &style type=&text/css&&
&&&&&&& body
&&&&&&&&&&& font-size: 12
&&& &/style&
&&& &script language=&javascript& type=&text/javascript&&
&&&&&&& //实例化XMLHttpRequest对象
&&&&&&& function InstantiateXMLHttp() {
&&&&&&&&&&& //Mozilla 浏览器
&&&&&&&&&&& if (window.XMLHttpRequest) {
&&&&&&&&&&&&&&& xmlhttp = new XMLHttpRequest();
&&&&&&&&&&&&&&& //设置MiME类别
&&&&&&&&&&&&&&& if (xmlhttp.overrideMimeType) {
&&&&&&&&&&&&&&&&&&& xmlhttp.overrideMimeType('text/xml');
&&&&&&&&&&&&&&& }
&&&&&&&&&&& }
&&&&&&&&&&& //IE浏览器
&&&&&&&&&&& else if (window.ActiveXObject) {
&&&&&&&&&&&&&&& //IE 7、8
&&&&&&&&&&&&&&& try {
&&&&&&&&&&&&&&&&&&& xmlhttp = new ActiveXObject(&Msxml2.XMLHTTP&);
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& //IE 6
&&&&&&&&&&&&&&& catch (e) {
&&&&&&&&&&&&&&&&&&& xmlhttp = new ActiveXObject(&Microsoft.XMLHTTP&);
&&&&&&&&&&&&&&& }
&&&&&&&&&&& }
&&&&&&&&&&& RequestProvince();
&&&&&&& function RequestProvince() {
&&&&&&&&&&& ddlProvince.options.length = 0; //请空下拉列表框
&&&&&&&&&&& xmlhttp.onreadystatechange = LoadP //设置当XMLHttpRequest对象的状态改变时调用的方法
&&&&&&&&&&& xmlhttp.open(&GET&, &DealRequestServices.ashx?requesttypeid=1&, true); //设置XMLHttpRequest对象请求的方式、地址和是否异步
&&&&&&&&&&& xmlhttp.send(null); //发送请求
&&&&&&& function LoadProvince() {
&&&&&&&&&&& if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
&&&&&&&&&&&&&&& var provinces = xmlhttp.responseText.split(&|&);
&&&&&&&&&&&&&&& for (var i = 0; i & provinces. i++) {
&&&&&&&&&&&&&&&&&&& var pro = provinces[i].split(&,&);
&&&&&&&&&&&&&&&&&&& ddlProvince.options.add(new Option(pro[1], pro[0]));
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& RequestCity();
&&&&&&&&&&& }
&&&&&&& function RequestCity() {
&&&&&&&&&&& ddlCity.options.length = 0;
&&&&&&&&&&& xmlhttp.onreadystatechange = LoadC
&&&&&&&&&&& xmlhttp.open(&GET&, &DealRequestServices.ashx?requesttypeid=2&provinceid=& + ddlProvince.value, true);
&&&&&&&&&&& xmlhttp.send(null);
&&&&&&& function LoadCity() {
&&&&&&&&&&& if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
&&&&&&&&&&&&&&& var cities = xmlhttp.responseText.split(&|&);
&&&&&&&&&&&&&&& for (var i = 0; i & cities. i++) {
&&&&&&&&&&&&&&&&&&& var city = cities[i].split(&,&);
&&&&&&&&&&&&&&&&&&& ddlCity.options.add(new Option(city[1], city[0]));
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& RequestCounty();
&&&&&&&&&&& }
&&&&&&& function RequestCounty() {
&&&&&&&&&&& ddlCounty.options.length = 0;
&&&&&&&&&&& xmlhttp.onreadystatechange = LoadC
&&&&&&&&&&& xmlhttp.open(&GET&, &DealRequestServices.ashx?requesttypeid=3&cityid=& + ddlCity.value, true);
&&&&&&&&&&& xmlhttp.send(null);
&&&&&&& function LoadCounty() {
&&&&&&&&&&& if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
&&&&&&&&&&&&&&& var counties = xmlhttp.responseText.split(&|&);
&&&&&&&&&&&&&&& for (var i = 0; i & counties. i++) {
&&&&&&&&&&&&&&&&&&& var county = counties[i].split(&,&);
&&&&&&&&&&&&&&&&&&& ddlCounty.options.add(new Option(county[1], county[0]));
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& ShowSelectValue();
&&&&&&&&&&& }
&&&&&&& function ShowSelectValue() {
&&&&&&&&&&& show.innerText = ddlProvince.options[ddlProvince.selectedIndex].text + ddlCity.options[ddlCity.selectedIndex].text + ddlCounty.options[ddlCounty.selectedIndex].
&&& &/script&
&body onload=&InstantiateXMLHttp()&&
&&& &table border=&0& cellpadding=&0& cellspacing=&0& style=&width: 600&&
&&&&&&& &tr&
&&&&&&&&&&& &td&
&&&&&&&&&&&&&&& 省:
&&&&&&&&&&& &/td&
&&&&&&&&&&& &td&
&&&&&&&&&&&&&&& &select id=&ddlProvince& onchange=&RequestCity()& style=&width: 120&&
&&&&&&&&&&&&&&& &/select&
&&&&&&&&&&& &/td&
&&&&&&&&&&& &td&
&&&&&&&&&&&&&&& 市:
&&&&&&&&&&& &/td&
&&&&&&&&&&& &td&
&&&&&&&&&&&&&&& &select id=&ddlCity& onchange=&RequestCounty()& style=&width: 120&&
&&&&&&&&&&&&&&& &/select&
&&&&&&&&&&& &/td&
&&&&&&&&&&& &td&
&&&&&&&&&&&&&&& 县:
&&&&&&&&&&& &/td&
&&&&&&&&&&& &td&
&&&&&&&&&&&&&&& &select id=&ddlCounty& onchange=&ShowSelectValue();& style=&width: 120&&
&&&&&&&&&&&&&&& &/select&
&&&&&&&&&&& &/td&
&&&&&&& &/tr&
&&& &/table&
&&& &br /&
&&& 结果:&span id=&show& style=&color: #0066&&&/span&
DealRequestServices.ashx中间处理程序文件内容如下:
&%@ WebHandler Language=&C#& Class=&DealRequestServices& %&
using System.W
using System.Web.UI;
using System.Web.UI.WebC
using System.C
using System.D
using System.T
public class DealRequestServices : IHttpHandler
&&& public void ProcessRequest (HttpContext context)
&&&&&&& SqlDataSource sqlds = new SqlDataSource();
&&&&&&& sqlds.ConnectionString = ConfigurationManager.ConnectionStrings[&connstr&].ConnectionS
&&&&&&& StringBuilder sb = new StringBuilder();
&&&&&&& DataV
&&&&&&& switch(context.Request.QueryString[&requesttypeid&].ToString())
&&&&&&&&&&& case &1&:
&&&&&&&&&&&&&&& sqlds.SelectCommand = &SELECT * FROM [Province]&;
&&&&&&&&&&&&&&& dv = sqlds.Select(DataSourceSelectArguments.Empty) as DataV
&&&&&&&&&&&&&&& foreach (DataRowView drv in dv)
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& sb.Append(drv[&p_id&].ToString() + &,& + drv[&p_name&].ToString() + &|&);
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&&
&&&&&&&&&&& case &2&:
&&&&&&&&&&&&&&& sqlds.SelectCommand = &SELECT [c_id],[c_name] FROM [City] WHERE [p_id] = & + context.Request.QueryString[&provinceid&];
&&&&&&&&&&&&&&& dv = sqlds.Select(DataSourceSelectArguments.Empty) as DataV
&&&&&&&&&&&&&&& foreach (DataRowView drv in dv)
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& sb.Append(drv[&c_id&].ToString() + &,& + drv[&c_name&].ToString() + &|&);
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&&
&&&&&&&&&&& case &3&:
&&&&&&&&&&&&&&& sqlds.SelectCommand = &SELECT [o_id],[o_name] FROM [County] WHERE [c_id] = & + context.Request.QueryString[&cityid&];
&&&&&&&&&&&&&&& dv = sqlds.Select(DataSourceSelectArguments.Empty) as DataV
&&&&&&&&&&&&&&& foreach (DataRowView drv in dv)
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&& sb.Append(drv[&o_id&].ToString() + &,& + drv[&o_name&].ToString() + &|&);
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&&
&&&&&&& context.Response.Write(sb.ToString().Substring(0, sb.Length - 1));
&&& public bool IsReusable
&&&&&&& get {
&&&&&&&&&&&
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:21422次
排名:千里之外
原创:10篇
转载:20篇
(1)(3)(10)(5)(1)(1)(1)(3)(1)(4)

我要回帖

更多关于 datasource 的文章

 

随机推荐