public void changeOptions(string gender, string productFamilyID, string clientID) { try { MySQLBusinessLogic bl = new MySQLBusinessLogic(); DataTable dt = new DataTable(); dt = bl.GetProductCategory_SubCategory(gender, Convert.ToInt32(productFamilyID)); List<List<string>> lstCh = new List<List<string>>(); var tt = (from c in dt.AsEnumerable() select c[0].ToString()).Distinct().ToList(); string mainStr = ""; for (int i = 0; i < tt.Count; i++) { var tt1 = (from t in dt.AsEnumerable() where t[0].ToString() == tt[i].ToString() select t[1]).ToList(); //lstCh.Add(tt1); var jsonSerialiser = new JavaScriptSerializer(); string js = jsonSerialiser.Serialize(tt1); mainStr += ",{\"P\":\"" + tt[i].ToString() + "\",\"c\":" + js + "}"; } mainStr = "[" + mainStr.Remove(0, 1) + "]"; Clients.Client(clientID).changedOptions(mainStr); } catch (Exception ex) { Clients.Client(clientID).changedOptions(""); } }