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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:58:57+00:00 2026-05-27T10:58:57+00:00

Controller’s Code int No= Convert.ToInt32(reqCookies[NO].ToString()); Student stud = db.Students.Single(n => n.No == No); return

  • 0

Controller’s Code

  int No= Convert.ToInt32(reqCookies["NO"].ToString());  
  Student stud = db.Students.Single(n => n.No == No);
  return View(stud);      

Im passing the No after the user logs In and want the record of that logged In person to be displayed which i have successfully done.My issue is again with the Date.When the record of the Logged In user is displayed the Date of birth is displayed along with the time.Like this 2/19/2001 12:00:00 AM, instead i only want the date part and not time something like this 19/2/2001.
To achieve this i have tried to convert the date in dd/MM/yyyy format

DateTime DOB=stud.DOB.tostring("dd/MM/yyyy");

Getting Error:No Overload for method ‘ToString()’ takes 1 Argument

Code in my View is like this:

<td>@Html.DisplayFor(model => model.DOB.ToString())</td>

And when i try to change the format in the View

<td>@Html.DisplayFor(model => model.DOB.ToString("dd/MM/yyyy"))</td>

Getting Error:No Overload for method ‘ToString()’ takes 1 Argument

Where can i make the conversion and how to truncate the time Part from getting displayed.

  • 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-27T10:58:58+00:00Added an answer on May 27, 2026 at 10:58 am

    You could use DisplayFormat in the model to format your date:

    [DisplayFormat(DataFormatString = "{0:dd/mm/yyyy}")]
    public DateTime myDate { get; set; }
    

    And then in the view:

    <td>@Html.DisplayFor(model => model.DOB)</td>
    

    Update:

    Alternatively, since the DisplayFor() will simply output the date without any tags, you could just display the date without the use of templated helpers:

    @Model.myDate.ToString("dd/MM/yyyy")
    

    Or to display in a textbox you could use:

    @Html.TextBox("Date", Model.myDate.ToString("dd/MM/yyyy"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Controller.cs is: public ActionResult ViewRequest(int id) { Job job = Jobs.GetJob(id); return View(job); }
Controller: public ActionResult Edit(string temp) { ViewBag.Time = DateTime.Now.ToString(hh:mm:ss); return PartialView(Edit); } Partial View:
My Controller Action accepts int id. What to do when calling from View ActionLink
I want my controller to return the right HTTP response code when the user
Controller action: public ActionResult Index() { ViewData[sample] = DateTime.Now.ToLongTimeString(); Thread.Sleep(3000); return View(); } View
My controller actions: [AcceptVerbs(HttpVerbs.Get)] public ActionResult Login() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult
Controller public ActionResult Create() { return View(new PageViewModel()); } [HttpPost] public ActionResult Create(Page page)
My controller method just return String value. When I called JSON from my view
My controller has this (testing) code: println domainInstance.hasErrors() render (view: edit, model: [domainInstance: domainInstance])
In controller level i used [ValidateInput(false)] and ValidateRequest=false in the view. Everything is fine

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.