locked
can i put datatable in cache in webmethod in asp.net? RRS feed

  • Question

  • User592456772 posted

    what i want to do is to keep my datatable in cache so that each time my webmethod called from the ajax autocomplete extender my data table dosen't gets filled from database again and again. To be brief i dont want to interact with database everytime i press a key in textbox. can this be done? Also The Ajax autocomplete extender is working dead slow why? my code is as below:

    [System.Web.Script.Services.ScriptMethod()]
        [System.Web.Services.WebMethod]
        public static List<string> GetCountries(string prefixText, int count)
        {
            DataTable dt = new DataTable();
            User objUser = new User();
            dt = objUser.GetDatatable();
     
            string Text = prefixText.ToUpper().ToString();
            List<string> LST = new List<string>();
     
             var query = from t in dt.AsEnumerable()
                         where t.Field<string>("DeptName").ToUpper().Contains(Text)
                         select new
                        {
                            DeptName = t.Field<string>("DeptName"),
     
    
                        };
     
             foreach (var i in query.Take(5))
             {
               LST.Add(i.DeptName.ToString().Trim());
             }
     
                 return LST;
        }
    an caching be done in webmethod?Thank you.


    Tuesday, November 19, 2013 6:30 AM

Answers

All replies