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

[Solved] getting error in panelBar

3 Answers 131 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Anjali
Top achievements
Rank 1
Anjali asked on 19 Jan 2011, 07:22 PM
I am trying to use the MVC panelbar in my code. I am using the dataBindingToController. My controller looks like this

public ActionResult DataBindingToModel()
      {
          DataContext cr = new DataContext();
          return View(cr.QryNavigation(4));
      }

where QryNavigation is my stored procedure. My view looks like

<%= Html.Telerik().PanelBar()
        .Name("PanelBar")
        .HtmlAttributes(new { style = "width: 300px;" })
        .BindTo(Model, mappings => 
        {
            mappings.For<tblSection>(binding => binding
                    .ItemDataBound((item, tblSection) =>
                    {
                        item.Text = tblSection.Section;
                    })
                    .Children(tblSection => tblSection.tblSectionLinks));
            mappings.For<tblSectionLink>(binding => binding
                    .ItemDataBound((item, tblSectionLink) =>
                    {
                        item.Text = tblSectionLink.Title;
                    }));
        })
%>

I dragged two tables in my LINQTOSQL one is tblSectionLink and another one is tblsection. I also dragged the stored procedure to the dbml page.

The stroed procedure already establishes the relationship between tblSection and tblsectionLinks. My stored procedure is like this
SELECT s.Section, sl.Title, sl.Link
        FROM dbo.tblSection AS s
        INNER JOIN dbo.tblSectionLinks AS sl ON s.PKSectionID = sl.FKSectionID
        WHERE s.AccessLevel <= @Access

I am getting an error :

Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
  
  
   
  
Line 10:         .Name("PanelBar")
Line 11:         .HtmlAttributes(new { style = "width: 300px;" })
Line 12:         .BindTo(Model, mappings => 
Line 13:         {
Line 14:             mappings.For<tblSection>(binding => binding
  

Any help will be greatly appreciated.

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 20 Jan 2011, 08:40 AM
Hello Nitu, 

Unfortunately the provided information is not sufficient. Please answer the following questions:
  1. Is the View of the correct type? You are using the Model so if it is not of the right type the binding code will not work.
  2. Are the namespaces imported? You are using mappings.For<tblSection> which will not work if the namespace of tblSection is not imported.
If your objects are Linq2SQL make sure the System.Data.Linq namespace is imported in web.config. Check this help article for further instructions.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Anjali
Top achievements
Rank 1
answered on 20 Jan 2011, 11:42 PM
Hi,

 Thanks Atanas, as soon as I added System.Data.Linq  in my web.config file. It started working right away. Thanks for all your help.

I was wondering if you or anyone else have an example that shows some action when the panel bar is clicked. I want to display a gridview on the right side of the panel bar when a particular item in panel bar is clicked.

Any help will be grealy appreciated.

Thanks again!!
0
Anjali
Top achievements
Rank 1
answered on 21 Jan 2011, 12:21 AM
I saw the example ClientSideEvents that response to the click of the panel bar, but I was wondering if anyone has example that grabs the data from the database and shows the data in the grid when the item in the panel bar is clicked.
Tags
PanelBar
Asked by
Anjali
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Anjali
Top achievements
Rank 1
Share this question
or