views:

307

answers:

1

i have a table T with fields id, parentid, name. i make relationship with own table so parentid=>id one to many, so if parentid=null it is a parent record, and if parentid not null it is child record

after mapping i have class with 2 new properties- T1 (Collection of T) and T2 (Instance of T)

so how can i fill dropdownlistfor, if i not have field parentid?

A: 

You should use the ID field for the DataValueField. That way it's always unique... or am I missing something?

rockinthesixstring
can you give examle? i try<%= Html.DropDownListFor(model=>model.ParentMenu.Id,Model) %> but it give error'System.Web.Mvc.HtmlHelper<mrhome.Models.Menu>' does not contain a definition for 'DropDownListFor' and the best extension method overload 'System.Web.Mvc.Html.SelectExtensions.DropDownListFor<TModel,TProperty>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TProperty>>, System.Collections.Generic.IEnumerable<System.Web.Mvc.SelectListItem>)' has some invalid arguments
kusanagi
Check out the answer I gave earlier tonight http://stackoverflow.com/questions/2346381/populating-dropdown-list-in-vb-net/2346395#2346395
rockinthesixstring
it's not mvc solution
kusanagi