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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:53:08+00:00 2026-06-12T23:53:08+00:00

Can someone tell me what I am doing wrong in the View for Dropdownlist?

  • 0

Can someone tell me what I am doing wrong in the View for Dropdownlist? I think it is expecting SelectList for dropdownlist? Thank you in advance.

My Model:

public class AppointmentModel
    {
        public int CustomerID { get; set; }
        public string LastName { get; set; }
        public string FirstName { get; set; }        
        public List<DateTime> ApptDates { get; set; }
    }

View:

@{
    var grid = new WebGrid(Model, rowsPerPage: ViewBag.RowsPerPage);    
    @grid.GetHtml(columns: grid.Columns(
        grid.Column(columnName: "LastName", header: "Last Name", canSort: true, format: @<text>@item.LastName</text>),
        grid.Column(columnName: "LastName", header: "First Name", canSort: true, format: @<text>@item.Firstname</text>),
        grid.Column(columnName: "ApptDates", header: "Appointment Dates", format: @Html.DropDownList(@item.ApptDates))
        ));                                             
}

The following changes fixed the issue:

public class AppointmentModel
    {
        public int CustomerID { get; set; }
        public string LastName { get; set; }
        public string FirstName { get; set; }        
        public DateTime ApptDt { get; set; }
        public IEnumerable<SelectListItem> ApptDatesSelectList { get; set; }
    }

View

@{
    var grid = new WebGrid(Model, rowsPerPage: ViewBag.RowsPerPage);    
    @grid.GetHtml(columns: grid.Columns(
        grid.Column(columnName: "LastName", header: "Last Name", canSort: true, format: @<text>@item.LastName</text>),
        grid.Column(columnName: "LastName", header: "First Name", canSort: true, format: @<text>@item.Firstname</text>),
        grid.Column(columnName: "ApptDates", header: "Appointment Dates", format: @<text>@Html.DropDownList("ApptDt", (IEnumerable<SelectListItem>)@item.ApptDatesSelectList)</text>)
        ));                                             
}
  • 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-06-12T23:53:09+00:00Added an answer on June 12, 2026 at 11:53 pm

    Assuming that the answer to my comment was that each appointment has one date, you first need to add a property to your model for the specific date:

    public class AppointmentModel
        {
            public int CustomerID { get; set; }
            public string LastName { get; set; }
            public string FirstName { get; set; }
            public DateTime AppointmentDate {get; set;}        
            public List<DateTime> ApptDates { get; set; }
        }
    

    Then you will need your potential appointments in a SelectList once you have done that, you can implement like so:

    @{
        var grid = new WebGrid(Model, rowsPerPage: ViewBag.RowsPerPage);    
        @grid.GetHtml(columns: grid.Columns(
            grid.Column(columnName: "LastName", header: "Last Name", canSort: true, format: @<text>@item.LastName</text>),
            grid.Column(columnName: "LastName", header: "First Name", canSort: true, format: @<text>@item.Firstname</text>),
            grid.Column(columnName: "ApptDates", header: "Appointment Dates", format: @<text> @Html.DropDownList(@item.AppointmentDate, yourSelectList )</text>)
            ));                                             
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone tell me what I'm doing wrong here? The inner class 'tab' is
Hi can someone tell me what i'm doing wrong in this jquery statement. I
Can someone who is way smarter than I tell me what I'm doing wrong..
can someone tell me what i am doing wrong here.. i am not getting
Can someone tell me what I'm doing wrong with the following Linq query? I'm
Can someone tell me what i am doing wrong here? I want the boxes
Can someone tell me what I'm doing wrong to package this as a module:
Can someone tell me where I am going wrong with this class. It is
Can someone tell me what I am doing wrong? I am trying to push
Can someone tell me what I am doing wrong here: function onAjaxDone(data) { var

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.