public ActionResult ExporttoExcel()
        {
            var customerdata = ManageCustomerService.CustomerDetails(0, "");
            List <ExportManageUserModel> ExportManageUserModel = new List <Models.ExportManageUserModel>();

            foreach (var item in customerdata)
            {
                var model = new ExportManageUserModel();
                model.CustomerNo         = item.CustomerId;
                model.CustomerName       = item.FirstName + item.LastName;
                model.Email              = item.Email;
                model.DateofRegistration = item.Date_of_Registration;
                model.AvailableCredits   = item.Availablecredits;
                model.NoOfEvents         = item.No_of_events;
                ExportManageUserModel.Add(model);
            }

            GridView gv = new GridView();

            gv.DataSource = ExportManageUserModel;
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=ManageUser.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 <CustomerModel> Customerlist = new List <CustomerModel>();
            var customerdata = ManageCustomerService.CustomerDetails(0, Alpha);

            foreach (var data in customerdata)
            {
                CustomerModel model = new CustomerModel();
                model.CustomerId           = data.CustomerId;
                model.FirstName            = data.FirstName;
                model.LastName             = data.LastName;
                model.Email                = data.Email;
                model.Contactno            = data.Contactno;
                model.Username             = data.Username;
                model.Password             = data.Password;
                model.CompanyName          = data.CompanyName;
                model.Date_of_Registration = data.Date_of_Registration;
                model.NoOfEvents           = data.No_of_events.Value;
                model.AvailableCredits     = data.Availablecredits.Value;
                Customerlist.Add(model);
            }

            return(Customerlist);
        }