Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8288943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:23:17+00:00 2026-06-08T12:23:17+00:00

This one is a bit tricky to explain so I accept more detail may

  • 0

This one is a bit tricky to explain so I accept more detail may be needed.

I’m working on an MVC3 project. I have two objects which have a many-to-many relationship so I designed the models as follows:

Object1

int ID
IEnumerable<Object2> Object2s

Object2

int ID
[Required]
string Name
IEnumerable<Object1> Objects1s

I then wanted to update Object1 using a form and this included a list of checkboxes for each of Object2 in Object2s. These would be checked if an Object2 should be removed from Object2s.The view looked similar to the following:

@Html.EditorFor(c => c.ID)

if (Model.Object2s.Count() > 0)
{
    @Html.EditorFor(c => c.Object2s)
}

Note – The EditorFor for c.Object2s is a custom EditorTemplate.

The problem I’ve got is when the server-side validation kicks in it reports an error because each of the Object2 objects doesn’t have its Name property set. The Name property not being important to me just to update Object1.

Did I go wrong by defining the objects with IEnumerable<Object> rather than IEnumerable<int>?

Or is there another way to stop the validation on Object2 kicking in?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:23:19+00:00Added an answer on June 8, 2026 at 12:23 pm

    OK I haven’t been able to work out exactly what I want but got around this particular problem by not binding the Object2s property. Instead I am picking up an int[] of selected checkboxes in the controller and using that to populate the Object2s property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one is a bit tricky to explain. I have a usercontrol with some
This might be a bit tricky setup but... I have this Silverlight project that
This is a bit of a tricky one. I have Document entities that are
Bit of a backstory to this one... I have an ASP.NET Login App on
I'm finding this a bit tricky! Maybe someone can help me on this one
Okay, have a bit of a tricky one (for me anyway, i'm pretty rubbish
This one is bit tricky , I created jsfiddle here http://jsfiddle.net/WXmcL/10/ to kinda replicate
This one seems a bit tricky to me. Sometime ago I already managed to
This one's a bit too tricky for my SQL-foo. What I need to do
Bit tricky question but this saves lot of time if you have to modify

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.