public static string[] GetAgentNames(string prefixText) { try { DataSet ds = new DataSet(); ClsBAL objBal = new ClsBAL(); ds = objBal.GetAgents(); string filteringquery = "Username LIKE'" + prefixText + "%'"; //Select always return array,thats why we store it into array of Datarow DataRow[] dr = ds.Tables[0].Select(filteringquery); //create new table DataTable dtNew = new DataTable(); //create a clone of datatable dt and store it into new datatable dtNew = ds.Tables[0].Clone(); //fetching all filtered rows add add into new datatable foreach (DataRow drNew in dr) { dtNew.ImportRow(drNew); } //return dtAirportCodes; List<string> airports = new List<string>(); for (int i = 0; i < dtNew.Rows.Count; i++) { airports.Add(dtNew.Rows[i]["Username"].ToString().Trim()); } return airports.ToArray(); } catch (Exception) { throw; } }
DataSet GetAgents() { try { ClsBAL objbal = new ClsBAL(); return objbal.GetAgents(); } catch (Exception ex) { // lblMsg.InnerHtml = ex.Message; throw; } }