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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:38:26+00:00 2026-05-31T04:38:26+00:00

Good Morning everybody. I’m a beginner in .Net languages and need an example to

  • 0

Good Morning everybody.

I’m a beginner in .Net languages and need an example to be able to go further.

So, my objective is to display dates and comments from a datatable, below general information about a client.

The view needs to become something like that :

name firstname :
adress :
phone number :
…

date1
comment1

date2
comment2
…

It was easy to automatically generate a strongly typed view with the general data. Now, I don’t get how to display the comments below.

Here is what I’ve already done into the controller

    ' GET: /Contacts/Details/5

    Function Details(id As Integer) As ActionResult
        Dim contact As contact = db.contact.Single(Function(c) c.idContact = id)
        Dim listMeet = New List(Of meeting)
        listMeet = (From d In db.meeting
                   Where d.FK_meet_contact = id
                   Select d).ToList()
        ViewBag.listeMeeting = listMeet
        Return View(contact)
    End Function

Into the view, I dis plenty of wrong things… Let’s show you the last one :

@ModelType MvcApplication4.contact
@Code
    ViewData("Title") = "Details"
    Dim list As List(Of Object) = ViewBag.listeMeeting
    Dim ligne As ListItemCollection

End Code

[…]

<fieldset>
  <legend><button onclick="togglefield('Meet')">Meetings</button></legend>
    <div class="Meet">

     @For Each ligne In ViewBag.listeMeeting
         @Html.Raw(ViewBag.listeMeeting)
     Next (ligne)

    </div>  
</fieldset>

What haven’t I well understood?

ps : I’m not a native english speaker, so, sorry if my english sucks

  • 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-31T04:38:28+00:00Added an answer on May 31, 2026 at 4:38 am

    You could use a view model instead of ViewBag:

    Public Class MyViewModel
        Public Property ContactDetails As Contact
        Public Property Meetings As IEnumerable(Of Meeting)
    End Class
    

    and then populate this view model in your controller and pass to the view for displaying:

    Function Details(id As Integer) As ActionResult
        Dim contact As contact = db.contact.Single(Function(c) c.idContact = id)
        Dim meetings =
            (From d In db.meeting
             Where d.FK_meet_contact = id
             Select d).ToList()
    
        Dim model = New MyViewModel With {
            .ContactDetails = contact,
            .Meetings = meetings
        }
        Return View(model)
    End Function
    

    and then have your view strongly typed to the view model:

    @ModelType AppName.MyViewModel
    
    <h2>@Model.ContactDetails.SomePropertyOfContact</h2>
    
    <fieldset>
        <legend>
            <button onclick="togglefield('Meet')">Meetings</button>
        </legend>
        <div class="Meet">
            @For Each meeting In Model.Meetings
                @meeting.SomePropertyOfMeeting
            Next
        </div>  
    </fieldset>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good morning, Apologies for the newbie question. I'm just getting started with ASP.NET internationalization
Good Morning All, I am creating an application to display List of applications with
Good Morning All, I am developing a new ASP.net MVC web application. Part of
Good Morning, Has anyone attempted to convert/migrate an ASP.net MVC web application project to
Good morning everybody. I have a question connected with controls and event handling. Lets
Good morning everybody. I am creating the form which will help my children to
Good morning to everybody, :) I have writen a code in C++ that reads
Good morning, I have to use the properties from DeviceNetworkInformation in my application. (http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation.devicenetworkinformation(v=vs.92).aspx)
Good morning folks, I'm just that beginner in json, I have a formated data
Good morning, I've got an ASP.NET MVC VB2008 .NET 3.5 project I'm upgrading 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.