這是從我的控制器的代碼片段無法投射型的「WhereListIterator`1 [Web.Model.Appointment]」爲類型「Web.Model.Appointment」對象
[HttpPost]
public ActionResult Cancel(string id,FormCollection collection)
{
//This is how I would like to declare appt but I cannot seem to correctly pass id into this method
//var appt = Application.Session.GetObjectFromOid<Appointment>(new ObjectId(id));
//I am trying to do it this way instead but I get an error
var appt = (Appointment)Application.Appointments.Where(a=>a.Id.Equals(collection["Id"]));
.....
}
這是錯誤我得到:無法投射類型'WhereListIterator`1 [Web.Model.Appointment]'的對象來鍵入'Web.Model.Appointment'。
這是我的看法:
<input type="button" value="Save" onclick="updateCancel(); return false;" /><button>Save</button>
,這是我的功能
function updateCancel() {
$('#cancel').ajaxSubmit({
});
}
那麼,爲什麼我收到此錯誤? 或者是否有一種方法可以將Model.Data.Id傳遞到我的函數中,以便我可以直接使用id?