Avatar of Stacie
StacieFlag for United States of America

asked on 

How to resolve the declation of TempData[""] in a static field?

Why can''t I use a TempData within a static method?

I'm getting the following error on this line of code :   empData["ss"] = resultsContainer

C# An object reference is required for the non-static field, method, or property


      public static XtraReport BuildReportObject(DailyEmployeeRecapSearchCriteria searchCriteria
            , Models.Employee LoggedInUser
            , System.Globalization.CultureInfo systemCultureInfo
            , ref XtraReport mainReport
            )
        {
            var resultsContainer = xxx.CustomReports.DailyEmployeeRecapService.GetReportResults(searchCriteria, LoggedInUser.CultureInfo, LoggedInUser.ID.Trim());
            resultsContainer.CustomerDetails.Select(s => s.CustomerNumberAndName = s.CustomerNumber.ToString().Trim() + " - " + (s.CustomerFirstNameLastNameOrCompany ?? "").Trim()).ToList();
            resultsContainer.CustomerDetails.Select(s => s.CustomerNumberAndName += (s.NewCustomer ? " - " + Tools.Language.Translate(Language.Keys.New, LoggedInUser.CultureInfo) + "!" : "")).ToList();

            empData["ss"] = resultsContainer

Open in new window

.NET ProgrammingC#

Avatar of undefined
Last Comment
Fernando Soto
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo