Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Friends
Since i am new to asp.net mvc
Getting this error
I want to show Profile to user in View

It shows this error
"The name 'o' does not exist in the current context"

What I have tried:

View
@model Test.Models.Customer 

            @o.CST_Name <br />
            @o.CST_Email <br />
            @o.CST_Gender <br />


Controller
public ActionResult ViewProfileCustomer(string id)
{
    var user = db.Customers.Single(u => u.CST_Username == id);

    return View(user);
}
Posted
Updated 6-May-17 8:01am

Use
@Model.CST_Name
 
Share this answer
 
Try this.

@model.CST_Name
 
Share this answer
 
Comments
Abdul Hannan 6-May-17 14:15pm    
@Ramesh Kumar Barik & @Matthew Dennis
Sir it still has error says "Object reference not set to an instance of an object.

"
Ramesh Kumar Barik 7-May-17 0:11am    
In which line it throws error?

Check you action method.
var user = db.Customers.Single(u => u.CST_Username == id);
As you are comparing the id with your name properties which may returns null.
Is is correct?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900