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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:13:58+00:00 2026-06-02T05:13:58+00:00

I have a view which I want to display, for which I have a

  • 0

I have a view which I want to display, for which I have a controller which accepts a string (StudentID). Here is my controller action:

public ActionResult ShowStudent(string StudentID)
{
    ViewData.Model = student.vwStudent.Where(s => s.StudentID == StudentID);
    return View();
}

Now here, StudentId’s have leading zeros in them. e.g. 00003345, 000000223 etc.
Hence, to display the view for a particular student, I have to enter the exact string “00003345” in the url: “http://Students/ShowStudent/00003345” I want to be able to display the view even if I enter “3345” in the url: “http://Students/ShowStudent/3345” but I get an error.

I have tried passing a Long(Int64) parameter instead of a string and converting StudentID to String in ViewData.Model like:

ViewData.Model = student.vwStudent.Where(s => s.StudentID == StudentID.ToString());

But I get an error:

LINQ to Entities does not recognize the method ‘System.String ToString()’ method, and this method cannot be translated into a store expression.

EDIT:
What is wrong with just parsing it to an Int64 like this:

ViewData.Model = student.vwStudent.Where(s => Int64.Parse(s.StudentID) == Int64.Parse(StudentID));
  • 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-02T05:13:59+00:00Added an answer on June 2, 2026 at 5:13 am

    Thanks all for the help, I took a bit of all of your advices and came to a solution that works for me.

    I Was able to resolve this by Casting in my SQL:

    CAST(CAST(StudentID AS bigint) AS nvarchar(33)) AS StudentID 
    

    And then converting it in my Controller:

    var StudentID = Convert.ToString(Int64.Parse(StudentId));
    
    ViewData.Model = student.vwStudent.Where(a => a.StudentID == StudentId);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Grouped Table View in which I want to display Contact details. But
I have a navigation controller which also has a table view. I want to
I have a custom UITableViewCell subclass, and a table view controller which I want
I have a django view generating a bunch of data which I want to
I have a custom view with several NSTextField controls for which I want to
I have a user database which I want the admin to be able view
I have outline view each element of which is checkbox. I want to set
In my view files, I have soundbites which i want to play through a
I want to implement this view But I have one question: The text which
i have view controller which contains a button which show the image library ,if

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.