//方法一:
string strTest = strTest.Substring(0, strTest.LastIndexOf(','));//取到从第0个下标开始到以,结尾的字符串变量然后赋值给字符串变量
//方法二:
<%@ WebHandler Language="C#" Class="ajaxTestPageHandler" %>
using System;
using System.Web;
public class ajaxTestPageHandler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
System.Text.StringBuilder sb = new System.Text.StringBuilder();//得到一个StringBuilder对象
BLL.StaticDataBll bll = new BLL.StaticDataBll();
System.Data.DataTable table= bll.getSex();
foreach (System.Data.DataRow row in table.Rows)
{
sb.Append(row["FName"].ToString()).Append(",");//把数据集中的每个字段数据使用逗号分隔开
}
context.Response.Write(sb.ToString().Trim(','));//使用Trim函数去掉字符串最后一个逗号
}
public bool IsReusable {
get {
return false;
}
}
}