[System.Web.Script.Services.ScriptMethod()] [System.Web.Services.WebMethod(EnableSession = true)] public static List<string> employeeid(string prefixText, int count) { OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString.ToString()); DataTable dtbl = new DataTable(); OracleDataAdapter da = new OracleDataAdapter(); List<string> Empid = new List<string>(); try { string str = "select '3'|| emp_code || '0' as empcode from empmaster where '3'|| emp_code || '0' like '" + prefixText + "%'"; dtbl = new DataTable(); da = new OracleDataAdapter(str, con); if (con.State == ConnectionState.Closed) { con.Open(); } da.Fill(dtbl); for (int i = 0; i < dtbl.Rows.Count; i++) { Empid.Add(dtbl.Rows[i]["empcode"].ToString()); } return Empid; } catch (Exception ex) { throw ex; } }
string result = ""; int[] indices = {1, 4, 15, 16}; // Just an example; you need to get the indices by searching via RegEx for example foreach (int i in indices) { result += Empid[i] + ","; // Create your string with values separated by comma } result = result.TrimEnd(','); // Remove last comma
catch (Exception ex) { throw ex; }
throw;
catch (Exception ex) { throw; }
try..catch
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)