Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8646633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:51:48+00:00 2026-06-12T12:51:48+00:00

I have a view that was using a standard Model but now I need

  • 0

I have a view that was using a standard Model but now I need to add information from two different models on the page. I created a ViewModel after doing some research to handle this. Now I am getting an error when tring to show my view saying:

DataBinding: ‘VirtualAuthtech.ViewModels.CMSCalculatorViewModel’ does not contain a property with the name ‘WORKCY’.

Here’s my viewmodel

namespace VirtualAuthtech.ViewModels
{
    public class CMSCalculatorViewModel
    {
        public CPT CPT { get; set; }
        public GPCI GPCI { get; set; }
    }
}

CPT is the first model I was originally using and then I need to add GPCI

Here is the ActionResult for my view

public ActionResult _CMSCalculator()
        {
            string CPTCode = string.Empty;
            string MOD = string.Empty;
            string GPCIPayID = "31146";
            string GPCIYear = "2011";
            if (Request.Params["CPT1"] != null)
            {
                CPTCode = Request.Params["CPT1"];
                MOD = Request.Params["MOD"];
            }
            return PartialView("_CMSCalculatorPanel", (string.IsNullOrEmpty(CPTCode) ? null as CMSCalculatorViewModel : CPTDataHelper.GetCPTGPCI(CPTCode, MOD, GPCIPayID, GPCIYear)));
        }

Here is the method to get the data from my models

    public static CMSCalculatorViewModel GetCPTGPCI(string CPTCode, string MOD, string GPCIPayID, string GPCIYear)
    {
        using (var DB = new VADataContext())
        {
            var view = new CMSCalculatorViewModel();
            if (String.IsNullOrWhiteSpace(MOD))
            {
                view.CPT = (from cpt in DB.CPTs
                            where cpt.CPT1 == CPTCode
                            select cpt).FirstOrDefault<CPT>();
                view.GPCI = (from gpci in DB.GPCIs
                             where gpci.PAYID == GPCIPayID && gpci.YEAR == GPCIYear
                             select gpci).FirstOrDefault<GPCI>();
            }
            else
            {
                view.CPT = (from cpt in DB.CPTs
                            where cpt.CPT1 == CPTCode && cpt.MOD == MOD
                            select cpt).FirstOrDefault<CPT>();
                view.GPCI = (from gpci in DB.GPCIs
                             where gpci.PAYID == GPCIPayID && gpci.YEAR == GPCIYear
                             select gpci).FirstOrDefault<GPCI>();
            }
            return view;
        }
    }

Now my view is using the new ViewModel and I’m trying to display a field:

<div style='float:left; width: 35px; margin: 0; padding: 0; text-align: center; color: #094ab2'>@VirtualAuthtech.CallbackPanelHelper.GetFieldNumber(Model, "WORKCY")</div>

And I’m getting an error in this piece of code:

public static double GetFieldNumber(object data, string fieldName)
        {
            object text = DataBinder.Eval(data, fieldName);
            if (text == null || text.ToString() == string.Empty)
                return 0;
            double number = Convert.ToDouble(text);
            return number;
        }

It’s saying my model does not contain the property of the field I’m looking for. Do I need to tell it to look in the CPT part of my view model?

This is the first ViewModel I’ve ever created so I might be going about this all wrong. Any help to send me in the right direction would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:51:49+00:00Added an answer on June 12, 2026 at 12:51 pm

    Why the call to GetFieldNumber? What would be wrong with the following line:

    <div style='float:left; width: 35px; margin: 0; padding: 0; text-align: center; color: #094ab2'>@Model.CPT.WORKCY</div>
    

    But if you have to use run-time binding, then maybe the line in your function should be:

    object text = DataBinder.Eval((CMSCalculatorViewModel)data.CPT, fieldName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using MVC2 with VS2010 I have a view that has two partial views
I am using javascript unobtrusive validation. I have a view model that I am
I have an SSIS package that queries data from a view using an SQL
I have a couple of properties in my view model that are display-only but
I have a Scouts model that requires two actions in addition to the standard
I have a view that renders a list elements using the following template :
I have a UIView on top of another view that's using a UITouchGesture. The
I have a simple query (in a mySQL view) that php is using to
I'm using Drupal 6. I have a custom view that needs to be filtered
I'm using .NET webforms. I have a grid view that can use Eval(Name) in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.