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

.BindTo Parameter Error

1 Answer 42 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.
WombatEd
Top achievements
Rank 1
WombatEd asked on 23 Jul 2010, 08:29 PM
I'm trying to set up a two-level PanelBar, using the "Binding to Hierarchical Model" example as my starting point, and I'm getting this error:

"The best overloaded method match for 'Telerik.Web.Mvc.UI.PanelBarBuilder.BindTo(System.Collections.IEnumerable, System.Action<Telerik.Web.Mvc.UI.NavigationBindingFactory<Telerik.Web.Mvc.UI.PanelBarItem>>)' has some invalid arguments.

The only change is that instead of drawing from "category" and "product" tables, I'm drawing from "Client" and "ActionItem" tables.  After pasting the PanelBar code into my page, I've switched the names, as follows:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="MvcApplicationCsharp.Models" %>
<%@ Import Namespace="Telerik.Web.Mvc" %>
<%@ Import Namespace="Telerik.Web.Mvc.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        <%= Html.Encode(ViewData["Message"]) %></h2>
    <table class="TableLayout" width="100%">
        <tr class="TableLayout">
            <td>
                <%=
Html.Telerik().PanelBar()
    .Name("PanelBar")
    .BindTo(Model, mappings =>
    {
        mappings.For<Client>(binding => binding
                .ItemDataBound((item, Client) =>
                {
                    item.Text = Client.ClientName;
                })
                .Children(Client => Client.ActionItems));
        mappings.For<ActionItem>(binding => binding
                .ItemDataBound((item, ActionItem) =>
                {
                    item.Text = ActionItem.ActionItemType.Text;
                }));
    })
 
                %>
            </td>
        </tr>
    </table>
</asp:Content>

Here's the controller class whose Index method invokes this view:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplicationCsharp.Models;
 
namespace MvcApplicationCsharp.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";
 
            DataClasses1DataContext ai = new DataClasses1DataContext();
 
            return View(ai.Clients);
        }
 
        public ActionResult About()
        {
            return View();
        }
    }
}

Thanks,

  Ed

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 26 Jul 2010, 09:13 AM
Hello WombatEd,

The most probable reason for this issue is a compiling error in some of the Action methods passed to the For  methods. If there is a compiling error C# compiler tries the next overload and throws the aforementioned exception.

Kind regards,
Georgi Krustev
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
Tags
PanelBar
Asked by
WombatEd
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or