using System.Data;
using System.Text;
protected void jsonData()
{
StringBuilder strBul = new StringBuilder();
string res = "";
try
{
DataBaseClass db = new DataBaseClass();
string sSql =sql语句
DataSet ds = db.GetDataSet1(sSql);
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
res = "[";
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
res = res + "{";
res = res + " \"id\": " + ds.Tables[0].Rows[i]["id"].ToString() + ",";
res = res + " \"value\": \"" + ds.Tables[0].Rows[i]["name"].ToString() + "\"";
res = res + "},";
}
res = res.Remove(res.LastIndexOf(","), 1);
res = res + "]";
}
else
{
res = "[]";
}
}
catch
{
res = "[]";
}
strBul.Append(res);
context.Response.Write(strBul);
}
//与我发布的移动端mobileSelect控件文章有关联