0

People, i have been breaking my back searching the internet for the answer to this. I need to know the code needed to show user details in a form, so that they can change and update their info?

I've tried with the following code, but i am hitting a brick wall?

@{
Layout = "~/_template1.cshtml";

var db = Database.Open("StayInFlorida");
var OwnerID = WebSecurity.CurrentUserId;
var FirstName = ("SELECT FirstName from OwnerInfo WHERE OwnerID='OwnerID'");


<h1>My Details</h1>

<form method="post">
<input>@FirstName</input>
<input type="submit" value="Insert" class="submit" />
</form>
}

I'm sure this is really wrong, but help on the net about this is very limited.

Gavin5511
  • 791
  • 5
  • 31

2 Answers2

2

Check out the awesome Getting Started tutorials on the ASP.NET Web Pages web site:

http://www.asp.net/web-pages/tutorials/introducing-aspnet-web-pages-2/getting-started

The links on the right go to all 9 parts of the article, including extensive details on adding and editing data in a database.

Eilon
  • 25,582
  • 3
  • 84
  • 102
0
<form action="" enctype="multipart/form-data" method="post">   
<input type="submit" value="@FirstName" class="submit" />
</form>

and then to update:

if(IsPost)
{
var FName = Request["FirstName"];

var insertQueryString = "UPDATE OwnerInfo Set FirstName=@0";

db.Execute(insertQueryString, FName);
}

and I don't think you need

<input>@firstName</input>
Dawood Awan
  • 7,051
  • 10
  • 56
  • 119