2013-02-26 65 views
0

人們,我一直在尋找互聯網尋找答案。我需要知道在表單中顯示用戶詳細信息所需的代碼,以便他們可以更改和更新他們的信息?在窗體中顯示更新信息 - 剃刀WebMatrix

我試着用下面的代碼,但我打磚牆?

@{ 
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> 
} 

我確定這確實是錯誤的,但在網絡上的幫助是非常有限的。

回答

0
<form action="" enctype="multipart/form-data" method="post"> 
<input type="submit" value="@FirstName" class="submit" /> 
</form> 

,然後更新:

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

var insertQueryString = "UPDATE OwnerInfo Set [email protected]"; 

db.Execute(insertQueryString, FName); 
} 

,我不認爲你需要

<input>@firstName</input>