joeharrison714 / MVCGrid.Net

http://mvcgrid.net
MIT License
74 stars 55 forks source link

Error loading Grid #59

Closed shefaliA closed 8 years ago

shefaliA commented 8 years ago

I am new to MVCGrid and trying to use it .I have followed instructions to setup my application - When I run my app ,I am getting below error -

----------------------My Config File -----------------------

public static class MVCGridConfig { public static void RegisterGrids() { GridDefaults defaultSet1 = new GridDefaults() { Paging = true, ItemsPerPage = 20, Sorting = true, NoResultsMessage = "Sorry, no results were found"

        };
        MVCGridDefinitionTable.Add("EmailTypeCodes1", new MVCGridBuilder<EmailTypeCodeViewModel>()
.WithQueryOnPageLoad(false)
.WithPreloadData(false)
 .AddColumns(cols =>
 {
    // Add your columns here
    cols.Add("CodeID")
     . WithHeaderText("Code")
      .WithValueExpression(i => i.EmailTypeCodes[0].CodeId); // use the Value Expression to return the cell text for this column
    cols.Add().WithColumnName("Code Description")
         .WithHeaderText("Code Description")
         .WithValueExpression(i => i.EmailTypeCodes[0].CodeDescription);
     cols.Add().WithColumnName("CodeStatus")
       .WithHeaderText("Active/Inactive Status")
       .WithValueExpression(i => i.EmailTypeCodes[0].CodeStatus);
 })
 .WithRetrieveDataMethod((context) =>
 {
    // Query your data here. Obey Ordering, paging and filtering paramters given in the context.QueryOptions.
    // Use Entity Framwork, a module from your IoC Container, or any other method.
    // Return QueryResult object containing IEnumerable<YouModelItem>
    return new QueryResult<EmailTypeCodeViewModel>()
     {
         Items = new List<EmailTypeCodeViewModel>(),
         TotalRecords = 0 // if paging is enabled, return the total number of records of all pages
    };
 }) );

} } ___Stack Trace : __ [ArgumentException: There is already a grid definition with the name 'EmailTypeCodes1'. Parameter name: name] MVCGrid.Web.MVCGridDefinitionTable.Add(String name, GridDefinition1 mapping) +688 MVCGrid.Web.MVCGridDefinitionTable.Add(String name, MVCGridBuilder1 builder) +75 ATCDWebUI.MVCGridConfig.RegisterGrids() in C:\Projects\ATCD_StandardGrid\ATCDWebUI\App_Start\MVCGridConfig.cs:25 ATCDWebUI.MvcApplication.Application_Start() in C:\Projects\ATCD_StandardGrid\ATCDWebUI\Global.asax.cs:19

I have not added this defination anywhere except RegisterGrids.Need help

shefaliA commented 8 years ago

I got it resolved.Thanks

LuckyN commented 7 years ago

How did you resolve it

sridharvadla commented 3 years ago

Remove this line of code from Global.asax : MVCGridConfig.RegisterGrids();