日期:2014-05-17 浏览次数:20445 次
for (int i = 0; i < dt.Rows.Count; i++)
{
string username = dt.Rows[i]["UserName"].ToString();
string u = "{'options':\"[{'names':'" + dt.Rows[i]["UserName"].ToString() + "','username':'" + dt.Rows[i]["UserName"].ToString() + "'}]\"}";
Context.Response.Write(u);
}
{'options':"[{'names':'陈先生','username':'陈先生'}]"}{'options':"[{'names':'严建军','username':'严建军'}]"}
{'options':"[{'names':'陈先生','username':'陈先生'},{'names':'严建军','username':'严建军'}]"}
string u = "{'options':\"[";
for (int i = 0; i < dt.Rows.Count; i++)
{
string username = dt.Rows[i]["UserName"].ToString();
u += "{'names':'" + dt.Rows[i]["UserName"].ToString() + "','username':'" + dt.Rows[i]["UserName"].ToString() + "'}";
}
u += "]\"}
Context.Response.Write(u);
var sb = new StringBuilder("{\"options\":[");
for (int i = 0; i < dt.Rows.Count; i++)
{
sb.AppendFormat("{\"names\":\"{0}\", \"username\":\"{0}\"}", dt.Rows[i]["UserName"].ToString().Replace("\\", "\\\\"").Replace("\"", "\\\""));
}
sb.Append("]}");
Context.Response.Write(sb.ToString());