We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

GridExportToPdf

When I try to use the GridExportToPdf function, I get the following error: Can anyone help?

Server Error in '/' Application.

Input string was not in a correct format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[FormatException: Input string was not in a correct format.]
   System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args) +10642901
   System.String.Format(IFormatProvider provider, String format, Object[] args) +63
   Syncfusion.Mvc.Grid.StringExtensions.FormatValue(String format, Object[] args) +61
   Syncfusion.Mvc.Grid.GridPDFExportActionResult`1.ProcessRecordCell(T data, GridColumn`1 column, PdfGridRow row, Boolean isTempColumnExport) +2403
   Syncfusion.Mvc.Grid.<>c__DisplayClass15.<ProcessRecordRow>b__11(GridColumn`1 column) +449
   Syncfusion.Linq.FunctionalExtensions.ForEach(IEnumerable`1 items, Action`1 action) +306
   Syncfusion.Mvc.Grid.GridPDFExportActionResult`1.ProcessRecordRow(T rows) +954
   Syncfusion.Mvc.Grid.<>c__DisplayClassb.<RenderGroupedRows>b__6(T record) +151
   Syncfusion.Linq.FunctionalExtensions.ForEach(IEnumerable`1 items, Action`1 action) +306
   Syncfusion.Mvc.Grid.GridPDFExportActionResult`1.RenderGroupedRows(GroupResult context, Int32 groupLevel) +2853
   Syncfusion.Mvc.Grid.GridPDFExportActionResult`1.<RenderGroupedData>b__3(GroupResult i) +39
   Syncfusion.Linq.FunctionalExtensions.ForEach(IEnumerable`1 items, Action`1 action) +306
   Syncfusion.Mvc.Grid.GridPDFExportActionResult`1.RenderGroupedData() +294
   Syncfusion.Mvc.Grid.GridPDFExportActionResult`1.ProcessGridContents() +149
   Syncfusion.Mvc.Grid.GridPDFExportActionResult`1.IterateElements() +196
   Syncfusion.Mvc.Grid.GridPDFExportActionResult`1.Export() +64
   Syncfusion.Mvc.Grid.GridPDFExportActionResult`1.ExecuteResult(ControllerContext context) +174
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +89
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629296
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

VIEW:
@(Html.Syncfusion().Grid<INRDesk.Models.Provider>("Provider_grid")
                .Datasource(Model)
                .Caption("Providers")
                .AutoFormat(Syncfusion.Mvc.Shared.Skins.Marble)
                .Column(column =>
                    {
                        column.Add(p => p.ProviderType).HeaderText("Provder Type").Width(100);
                        column.Add(p => p.FullName).HeaderText("Patient").TextAlign(TextAlignment.Left);
                        column.Add("Delete").HeaderText("Delete").Format("<a class=\"TemplateCell\" rel='nofollow' href=\"Provider/Delete?id={ProviderID}\">Delete").Width(50);
                        column.Add("Edit").HeaderText("Edit").Format("<a class=\"TemplateCell\" rel='nofollow' href=\"Provider/Edit?id={ProviderID}\">Edit").Width(50);
                        column.Add("Details").HeaderText("Details").Format("<a class=\"TemplateCell\" rel='nofollow' href=\"Provider/Details?id={ProviderID}\">Details").Width(50);
 
                    })
 
                 .EnablePaging()
                 .EnableRowHover(true)
                 .EnableAlternateRowStyling()
                 .AllowKeyboardNavigation(true)
                 //.EnableGrouping()
                 .Grouping( group => group.GroupDescriptors(grouped => 
                    grouped.Add(p => p.ProviderType)))
                 .EnableSorting()
                 .PageSettings(page=>page.AllowPaging(false).PageSize(18).PageCount(5))        
                 .Scrolling(scroll =>
                    {
                        scroll.Height(400).AllowVirtualScrolling(true).VirtualScrollMode((VirtualScrollMode)Syncfusion.Mvc.Grid.VirtualScrollMode.Normal);
                    })
                .ToolBar(toolbar =>
                    {
                        toolbar.Add(GridToolBarItems.PDFExport, "PDF Export");
                    })
                .Mappers(map =>
                    {
                        map.ExportPdfAction("ProvidersExportToPDF");
                    })
                 )
CONTROLLER: 
public ActionResult ProvidersExportToPDF(PagingParams args)
        {
            
            IEnumerable data = new INRDeskContext().Providers.ToList();
            return data.GridExportToPDF<Provider>("Providers.pdf"PdfVersion.Version1_7, args.ExportOption);
        }
MODEL:
public class Provider
    {
        [ScaffoldColumn(false)]
        public int ProviderID { getset; }
 
        [Required]
        [Display(Name = "Provider Type")]
        public string ProviderType { getset; }
 
        [Required]
        [Display(Name = "Last Name")]
        public string LastName { getset; }
 
        [Display(Name = "First Name")]
        public string FirstName { getset; }
 
        [Display(Name = "Second Name")]
        public string SecondName { getset; }
 
        [Display(Name = "Prefix")]
        public string Prefix { getset; }
 
        [Display(Name = "Suffix")]
        public string Suffix { getset; }
 
        [Display(Name = "Title")]
        public string Title { getset; }
 
        [Display(Name = "Address")]
        [DataType(DataType.MultilineText)]
        public string Address { getset; }
 
        [Display(Name = "City")]
        public string City { getset; }
 
        [Display(Name = "State")]
        public string State { getset; }
 
        [Display(Name = "Country")]
        public string Country { getset; }
 
        [Display(Name = "Zip")]
        public string Zip { getset; }
 
        [Display(Name = "Phone")]
        public string Phone { getset; }
 
        [Display(Name = "Mobile")]
        public string Mobile { getset; }
 
        [Display(Name = "Fax")]
        public string Fax { getset; }
 
        [Display(Name = "Email")]
        [DataType(DataType.EmailAddress)]
        public string Email { getset; }
 
        [ScaffoldColumn(false)]
        [Display(Name = "Provider")]
        public string FullName
        {
            get
            {
                return LastName + ", " + FirstName + " " + SecondName;
            }
        }


1 Reply

RD Rakesh D Syncfusion Team May 15, 2013 04:03 AM UTC

 

Hi Patrick,

 

Thank you for your interest in Syncfusion products.

 

We regret to let you know that we can only provide you the solution for above query only through Direct-Trac incident, so could you please create the incident in your direct trac account.

 

You can login to your Direct-Trac account using the credentials and password that are provided by our sales team to create incident. I would request you to use the following link to login to your DT account.

 

http://www.syncfusion.com/account/Logon

 

Please let us know if you need further assistance. We would be happy to assist you.

 

Regards,

Rakesh D


Loader.
Live Chat Icon For mobile
Up arrow icon