GetProByCol.ashx
上传用户:szhf331
上传日期:2022-06-22
资源大小:1032k
文件大小:1k
- <%@ WebHandler Language="C#" Class="GetProByCol" %>
- using System;
- using System.Web;
- using System.Data;
- using System.Text;
- using System.Web.UI;
- public class GetProByCol :IHttpHandler
- {
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "application/x-javascript";
- string su = context.Request.QueryString["colid"];
- StringBuilder sb = new StringBuilder();
- if (su != "")
- {
- DataTable dt = new student.BLL.res_pro().GetList("col_id=" + su).Tables[0];
-
- #region 如果dt为空的情况直接返回空字符串
- if (dt.Rows.Count==0)
- {
- context.Response.Write("");
- return;
- }
- #endregion
-
- foreach (DataRow vvv in dt.Rows)
- {
- sb.AppendFormat("({0}name:'{1}',value:'{2}'{3}),", "{", vvv["pro"].ToString(), vvv["id"].ToString(), "}");
- }
- string result = sb.ToString().Substring(0, sb.Length - 1);
- result = "({aaa:[" + result + "]})";
- context.Response.Write(result);
- }
- else
- {
- context.Response.Write("");
- }
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }