开发者

doesnt work when i declare it as parameter?

开发者 https://www.devze.com 2022-12-20 09:09 出处:网络
If i declare the Bind attribute as a parameter on the method, it doesnt work as it expected [AcceptVerbs(HttpVerbs.Post)]

If i declare the Bind attribute as a parameter on the method, it doesnt work as it expected

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create([Bind(Exclude="ID")]int ServiceId, Event evnt)
        {
            var service = dbSrc.GetAll().WithI开发者_如何转开发D(ServiceId).SingleOrDefault();
            if (service == null)

But if i declare it on the class level, it works!

[Bind(Exclude = "ID")]
    partial class Event
    {

The form firing the create action is in the usercontrol and i am using asp.net mvc 1 ?

My db setup is fine. The id column is primary key and auto generated.

What might be the reason ? or it s a bug in the version 1.0 ?

Thanks in advance


How about this:

public ActionResult Create(int ServiceId, [Bind(Exclude="ID")]Event evnt)

instead? I'm betting ServiceId has no ID property.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号