This is a migrated thread and some comments may be shown as answers.

[Solved] Model Binding Issue

3 Answers 172 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Roberto
Top achievements
Rank 1
Roberto asked on 19 Oct 2010, 05:39 PM

Dear All

I tried to understand model Binding for treeview and menu.
I was working with Centers and ProjectCenters in relationship 1 - * (one to many) and i tried more and more times to utilize the above snippet.

<%= Html.Telerik().TreeView()
        .Name("TreeView")
        .Theme("web20")
        .BindTo(Model, mappings =>  
        {
            mappings.For<Centers>(binding => binding
                    .ItemDataBound((item, category) =>
                    {
                        item.Text = category.txtName;
                    })
                    .Children(category => category.ProjectCenter));
            mappings.For<ProjectCenters>(binding => binding
                    .ItemDataBound((item, product) =>
                    {
                        item.Text = product.ProjectName;
                    }));
        })
%>

After a lot of errors when using mappings => mappings.For<>() and after examine some example with northwind entities, i found that when using the same Entity and EntitySet name the previous snippet work fine.
Is this the correct implementation or I've missed some step?

Thanks in advance

Roberto

3 Answers, 1 is accepted

Sort by
0
Eti
Top achievements
Rank 2
answered on 20 Oct 2010, 09:07 AM
Hi, 
Just a wild guess, but I remember having to do this on a project for the desired overload to be selected:

instead of

 .BindTo(Model, mappings =>  

try this:

 .BindTo((IEnumerable)Model, mappings =>  

Not sure this is related but hope it helps,
Eti
0
Roberto
Top achievements
Rank 1
answered on 20 Oct 2010, 09:49 AM
Thank you Eti
, I Hope to try this solutions with a mock entity repository.

I think it could be very interesting solution to my problems :)


Roberto
0
leon
Top achievements
Rank 1
answered on 30 Mar 2011, 05:36 PM
I have the same problem
(IEnumerable)Model  works  
but why this happen
Tags
General Discussions
Asked by
Roberto
Top achievements
Rank 1
Answers by
Eti
Top achievements
Rank 2
Roberto
Top achievements
Rank 1
leon
Top achievements
Rank 1
Share this question
or