public ActionResult ExporttoExcel()
        {
            var customerdata = ManageCustomerService.ManageEvents(0, Convert.ToString(TempData["SearchTitle"]));
            List <ManageEventModel> ManageEventModel = new List <Models.ManageEventModel>();

            foreach (var item in customerdata)
            {
                var model = new ManageEventModel();
                model.CustomerName   = item.Name;
                model.EventName      = item.EventName;
                model.EventStartDate = item.EventStartDate;
                model.EventEndDate   = item.EventEndDate;
                model.RegisteredUser = item.TotalCount;
                model.ReferredUser   = item.ReferredUsers;
                ManageEventModel.Add(model);
            }

            GridView gv = new GridView();

            gv.DataSource = ManageEventModel;
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=ManageEvent.xls");
            Response.ContentType = "application/ms-excel";
            Response.Charset     = "";
            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            gv.RenderControl(htw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
            return(RedirectToAction("Index"));
        }
        private IEnumerable GetData(int SearchRecords, string SearchTitle, string Alpha)
        {
            SearchTitle = SearchTitle.Trim().ToLower();
            Alpha       = Alpha.Trim().ToLower();
            List <ManageEventModel> Customerlist = new List <ManageEventModel>();
            var customerdata = ManageCustomerService.ManageEvents(0, SearchTitle);

            foreach (var data in customerdata)
            {
                ManageEventModel model = new ManageEventModel();
                model.CustomerName   = data.Name;
                model.EventName      = data.EventName;
                model.EventStartDate = data.EventStartDate;
                model.EventEndDate   = data.EventEndDate;
                model.RegisteredUser = data.TotalCount;
                model.ReferredUser   = data.ReferredUsers;
                Customerlist.Add(model);
            }

            return(Customerlist);
        }