Ejemplo n.º 1
0
        public static string GetClientDataRow(DataTable dt, string[] aColName)
        {
            List <string> aRow = new List <string>();

            for (int rw = 0, rw2 = dt.Rows.Count; rw < rw2; rw++)
            {
                DataRow dr = dt.Rows[rw];

                string[] aNameValue = new string[dt.Columns.Count];
                for (int cl = 0, cl2 = dt.Columns.Count; cl < cl2; cl++)
                {
                    object oValue = dr[cl];

                    string Text = CScript.GetValueForJson(oValue);

                    //JSON 형식을 리턴할 때 Name에 큰 따옴표를 붙여야만 에러를 내지 않음.
                    aNameValue[cl] = "\"" + aColName[cl] + "\":" + Text;
                }
                string NameValueList = string.Join(", ", aNameValue);
                aRow.Add("{ " + NameValueList + " }");
            }

            string RowList = "[ " + string.Join(",\r\n", aRow.ToArray()) + " ]";

            return(RowList);
        }