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 433783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:12:30+00:00 2026-05-12T20:12:30+00:00

How do I go about passing two sets of Data to a view in

  • 0

How do I go about passing two sets of Data to a view in ASP.NET MVC?

I’ve tried a couple of things and neither have worked so I’ve come to the simple conclusion: I’m doing it wrong.

I have 2 queries:

callRepository.FindOpenCalls() and callRepository.FindAllMyCalls(user)

and I want to out put both sets of data to one view via 2 partial views (OpenCalls.ascx and AssignedCalls.ascx respectively).

I’d like to do this using the Index() function in my CallsController.vb.

At the moment I have:

'
' GET: /Calls/

<Authorize()> _
Function Index() As ActionResult
    ViewData("OpenCallCount") = callRepository.CountOpenCalls.Count()
    ViewData("UrgentCallCount") = callRepository.CountUrgentCalls.Count()
    ViewData("HighCallCount") = callRepository.CountHighCalls.Count()
    ViewData("NormalCallCount") = callRepository.CountNormalCalls.Count()
    ViewData("LowCallCount") = callRepository.CountLowCalls.Count()

    ViewData("MyOpenCallsCount") = callRepository.CountMyOpenCalls(Session("LoggedInUser")).Count()
    ViewData("UserName") = Session("LoggedInUser")

    Dim viewOpenCalls = callRepository.FindAllOpenCalls()
    Dim viewMyOpenCalls = callRepository.FindAllMyCalls(Session("LoggedInUser"))

    Return View(viewOpenCalls)
End Function

Which returns just the open calls obviously, but I’d like to return both viewOpenCalls and viewMyOpenCalls.

How would I go about it?

Would showing my LINQ help?

Thanks for any help in advance.

  • 1 1 Answer
  • 1 View
  • 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-05-12T20:12:30+00:00Added an answer on May 12, 2026 at 8:12 pm

    The best way to pass data to a view is to actually have a specific ViewData for your view, containing only the data needed.

    Instead of having magic strings ( ViewData("MyOpenCallCount") ) define a specific class containing all the data needed for this view (sorry if my VB.Net is a bit rusty):

    public class CallInfo
        public OpendCallCount as int
        public UrgentCallCount as int   
        'etc.
    end class
    
    public class CallViewData
        public AllCalls as CallInfo
        public MyCalls as CallInfo
        public UserName as String
    end class
    

    And use a strongly typed view deriving from ViewPage(of CallViewData), this way you have intellisense and you don’t need to struggle with hardcoded strings to get to your information.

    You populate CallViewData with info from both all calls and the current user calls, return this instance.

       Dim data as new CallViewData
       data.AllCalls = new CallInfo {OpenCallCount = ...  }
       'etc
       return View(data)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big object say MyApplicationContext which keeps information about MyApplication such as
I have two files: metadata.csv: contains an ID, followed by vendor name, a filename,
I know about passing the context to templates, but I am bit confused with
I have written an application that allows a user to define a query, run
I have just discovered the joy of bitflags. I have several questions related to
For the current app I am writing I have elected to place all database
I think this is what the asker of this question is getting at, but
I am designing a class library designed to solve a wide scope of problems.
I'm attempting to build a custom control for Formtastic that takes a latitude and

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.