List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
foreach (DataRow row in table.Rows)
{
Dictionary<string, object> dict = new Dictionary<string, object>();
foreach (DataColumn col in table.Columns)
{
dict[col.ColumnName] = row[col];
}
list.Add(dict);
}
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
String abcd = serializer.Serialize(list).Replace("[", "").Replace("]", "");
HttpContext.Current.Response.BinaryWrite(encoding.GetBytes(abcd));