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

Related Questions

I am facing some problem with MySQL database. actually It was fast when I
I'm having a problem with XSL variables. I know that once declared, the value
I am a newbie in this field so please excuse my silly mistakes :)
I am having a column series with two columns side by side. <mx:ColumnSeries xField=period
I am new to iphone development.I am creating a map application.Now i am facing
I have a jasper report that I'm displaying. Now I have an icon to
What I have? I have a web part on which I am displaying a
I've an image gallery, that displays images in a 5X5 matrix. Each image has
in my scenario I have a Linq2SQL Data backend. my Dataobjects implement IDataErrorInfo to

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.