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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:37:43+00:00 2026-05-22T02:37:43+00:00

I wrote something like this in the controller. public ActionResult Giris() { ViewData[Tarif] =

  • 0

I wrote something like this in the controller.

   public ActionResult Giris()

    {

        ViewData["Tarif"] = (from t in _entities.Tarif

                             join k in _entities.Kullanici on t.KID equals k.KID

                             select new {KAdi = k.KAdi, TAdi = t.TAdi})

                             .Take(4);



        return View();

    }

I am using it as below in the view page.

<% foreach (var item in (IEnumerable<dynamic>)ViewData["Tarif"]) {  %>

<div class="begenilen-video" style="float:left">

<img class="video-resmi" alt="reklam" src="../../Uygulama/Resimler/Reklam/1.jpg" />

<span class="benzer-yemek-tarifi-adi"></span><%=item.TAdi %><br />

<span class="benzer-yemek-tarifi-ekleyen">Ekleyen: </span><br />

<span class="benzer-yemek-tarifi-izlenme">İzlenme: </span>

</div>

<% } %>

However,I am receive the error in the select statement.How do I invoke the items in the view page?

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. Editorial Team
    Editorial Team
    2026-05-22T02:37:44+00:00Added an answer on May 22, 2026 at 2:37 am

    As a guess because you haven’t posted the error:

    The object being stored in ViewData["Tarif"] will be of the type IQueryable<T> where T is an anonymous object and in your view you are casting to IEnumerable<dynamic>. IQueryable is also lazily loaded so you will be trying to execute your query once the object has been disposed.

    You should really create a strongly typed view model

    public class ViewModelType {
    
      public IEnumerable<TarifType> Tarif { get; set; }
    
    }
    

    Tarif type

    public class TarifType {
    
      public string KAdi { get; set; }
      public string TAdi { get; set; }
    
    }
    

    controller

    public ActionResult Giris() {
    
      var viewModel = new ViewModelType();
    
      viewModel.Tarif = (from t in _entities.Tarif
                           join k in _entities.Kullanici on t.KID equals k.KID
                           select new TraifType { KAdi = k.KAdi, TAdi = t.TAdi }
                         ).Take(4)
                         .ToList();
    
       return View(viewModel);
    }
    

    view

    <% foreach (var item in viewModel.Tarif) {  %>
      <div class="begenilen-video" style="float:left">
        <img class="video-resmi" alt="reklam" src="../../Uygulama/Resimler/Reklam/1.jpg" />
        <span class="benzer-yemek-tarifi-adi"></span><%=item.TAdi %><br />
        <span class="benzer-yemek-tarifi-ekleyen">Ekleyen: </span><br />
        <span class="benzer-yemek-tarifi-izlenme">İzlenme: </span>
      </div>
    <% } %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While playing around with regexps in Scala I wrote something like this: scala> val
I was recently working with a DateTime object, and wrote something like this: DateTime
Eg. can I write something like this code: public void InactiveCustomers(IEnumerable<Guid> customerIDs) { //...
I often find I want to write code something like this in C#, but
Now I am working with yii framework and I'd like to wrote something like
I have a few lines of code that start something like this: $trailheads =
I have a controller that looks like this for importing xml to my site:
I want to write something like Skype, i.e. I have a constant audio stream
As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...)
I want to write something that acts just like confirm() in javascript, but I

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.