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

  • Home
  • SEARCH
  • 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 164209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:42:13+00:00 2026-05-11T11:42:13+00:00

I am facing problem in displaying the column field value at the view. I

  • 0

I am facing problem in displaying the column field value at the view.

I am returning view like follows.

var TicketList = (from T in db.Tickets                   where  T.Title.Contains('a')                   select new {                         customerName = (                              from cname in db.Customers                              where cname.CustomerId == T.CustomersId                              select cname.FirstName + cname.LastName                         ) ,                         Title = T.Title                   }).ToList();   return View('SearchTicketsResult',TicketList); 

and at the view page I have

<%foreach (TicketList ti in (IEnumerable)ViewData.Model) {%>     <%=ti.Title%><br />     <%=ti.customerName %> <% } %> 

I am not able to list customername or the title in the page. It says ‘The type or namespace name ‘TicketList’ could not be found (are you missing a using directive or an assembly reference?)’

Can someone guide me please.

Thanks in advance.

  • 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. 2026-05-11T11:42:13+00:00Added an answer on May 11, 2026 at 11:42 am

    ‘TicketList’ is the variable name for a list of an anonymous type. There is no ‘TicketList’ type. Casting from anonymous types can be done (‘by example’), but is very brittle, and I simply don’t recommend you use an anonymous type for this.

    One option would be to declare my own type (in the UI’s ‘model(s)’ folder) – for example TicketSummary / TicketLite (etc), with a Title and CustomerName. Then use this type:

    public class TicketSummary {       public string CustomerName { get; set; }      public string Title { get; set; } }  var ticketList = (from t in db.Tickets                   where  t.Title.Contains('a')                   select new TicketSummary                   {                       CustomerName = (                           from cname in db.Customers                           where cname.CustomerId == t.CustomersId                           select cname.FirstName.ToString()                       ).FirstOrDefault(),                       Title = t.Title                   }).ToList(); return ticketList; 

    Then you should be able to use:

    <%foreach (TicketSummary ts in (IEnumerable<TicketSummary>)ViewData.Model) {%>     <%=ts.Title%><br />     <%=ts.customerName %> <% } %> 

    In reality, I’d probably offload this work to a repository, and have a repository method that returns a list of the summary type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 231k
  • Answers 231k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the following function like this: Image('/path/to/original.image', '1/1', '150*', './thumb.jpg');… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer Check you database schema to see if the field (referenced… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer I figured out the problem - there was a session… May 13, 2026 at 2:13 am

Related Questions

I have a Document class that is responsible for holding the document that will
I have created two forms in my Windows Application. One Form acts as a
What I want? I want to display weather information on my page. I want
I want the users to upload files through my webapp I am developing in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.