2

I have a dropdown list on an ASP.NET MVC project that I am pretty sure is not binding to my model because of my nhibernate mapping. I have tried many variations on the asp mvc side resulting in this post here. MVC side of things seems fine I believe the issue may be that my object is trying to bind, but my mapping is out of whack.

My mapping is:

<many-to-one name="Project" lazy="false"
       class="AgileThought.ERP.Domain.Property.Project"
       column="ProjectGUID" />

My View gives an error saying that the GUID from the dropdownList selected value is not valid. Which I think may be that it is trying to push the GUID into my related project object. The value 'fd38c877-706f-431d-b624-1269184eeeb5' is invalid.

My related project list binds to the dropdown list just fine, it is just not binding to my models Project entity.

Does the related Project entity need to know about its relationship? Its really just a lookup list.

Many thanks for your time and best regards, Rod

1
  • please post the full stack trace Commented Apr 30, 2010 at 10:48

1 Answer 1

2

You'd probably need a custom binder that can essentially do this...

entity.Project = session.Load<Project>(selectedValue);

I think Sharp Arch has something like this...check out this + helper method.

If you want to keep it simple, maybe just do it manually.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks dotjoe, I am able to manually populate it the project, I was hoping to bind it to the model. Im really not sure if the issue is with nhybernate or MVC. Im essentially trying to get a dropdownlist for to bind to the model.Project property like textboxes do.
Hi dotjoe, do i assign this in the controller? Rod
Sure, if going manual route, then the controller would be the place to do it. If you went with a custom binder, I think you'd need to have a ISession available outside the controller action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.