小编car*_*rye的帖子

仅选择美国时区

有一种简单的方法可以在美国创建仅限时区的列表吗?我正在使用此代码,但它产生每个时区,我只想要太平洋,中部,山区和东部

public List<TimeZoneInfo> _timeZones = TimeZoneInfo.GetSystemTimeZones().ToList();
Run Code Online (Sandbox Code Playgroud)

c# timezone

10
推荐指数
1
解决办法
7605
查看次数

无法将类型为'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"]));
   .....
}
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:无法将'WhereListIterator`1 [Web.Model.Appointment]'类型的对象强制转换为'Web.Model.Appointment'.

这是我的看法:

<input type="button" value="Save" onclick="updateCancel(); return false;" /><button>Save</button>
Run Code Online (Sandbox Code Playgroud)

这是我的功能

 function updateCancel() {
    $('#cancel').ajaxSubmit({

    });
    }
Run Code Online (Sandbox Code Playgroud)

那我为什么会收到这个错误呢?或者有没有办法将Model.Data.Id传递给我的函数,以便我可以只使用id?

c# asp.net-mvc-2

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

c# ×2

asp.net-mvc-2 ×1

timezone ×1