开发者

Model binding problem

开发者 https://www.devze.com 2023-03-18 19:50 出处:网络
I have this code public class Room { public string Id { get; set; } public List<person> people { get; 开发者_Python百科set;}

I have this code

public class Room
{
    public string Id { get; set; }
    public List<person> people { get; 开发者_Python百科set;}        
}
}

public class person
{
    public int Id { get; set; }
    public string Name { get; set; }
}

I'm trying to bind a list of person and place it in the room object

I create my textboxes for person name and I name them people[index].Name I can bind them to a list of person (by removing people) but I cant bind them to the Rooms people object. Is there a way?


public ActionResult([Bind(Prefix="people")]person p)


Hi I figured out the answer

In mvc 2 you need an index and in 3 you don't (wrt Non-Sequential Indices). This site provides some insight

I'm sorry I never give you guys enough information to answer this question. I work with multiple solutions it's difficult for me to keep track right now.

Thanks for the reply.

0

精彩评论

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