Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7437227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:21:58+00:00 2026-05-29T10:21:58+00:00

I am using the latest version Telerik MVC controls . I am using ASP.NET

  • 0

I am using the latest version Telerik MVC controls. I am using ASP.NET MVC 3 with razor.

I have a grid that lists all of my grant applications. I am wanting to use a grid that loads these grant applications via AJAX. I also need to create a client template column that has action links. These action links can vary depending on the state of each grant application.

I worked through the article at: http://gedgei.wordpress.com/2011/07/02/telerik-mvc-grid-actionlink-column/. I implemented the code as is and it works, I can create a client template column with a link in it. In my scenario I need to be able to pass in 2 parameters to the helper method, like:

column.ActionLink("Open", "Edit", "GrantApplication", item => new { id = item.Id, applicationStateId = item.GrantApplicationStateType.Id });

How I eventually implement this method in the end will change, but for now I am playing with these 2 input parameters to see how they are passed through and how I can retrieve them in the helper method.

The first question that I have regarding the article, why does the writer do the following:

var builder = factory.Template(x =>
{
     var actionUrl = urlHelper.Action(action, controller, routeValues.Compile().Invoke(x));

     return string.Format(@"<a href=""{0}"">{1}</a>", actionUrl, linkText);
});

I can only assume that this is the server side template that is created? But nothing displays in the grid, so how do I skip this part and go directly to the client template (this is what I actually need).

The following part is also confusing because when the first parameter (id) check comes through then it is of type ParameterExpression so it goes into the true part of the if, but when the second parameter (grant application state id) comes in then it is of another type (not sure what) so then it goes into the false part of the if statement:

switch (argument.NodeType)
{
     case ExpressionType.Constant:
          value = ((ConstantExpression)argument).Value;
          break;

     case ExpressionType.MemberAccess:
          MemberExpression memberExpression = (MemberExpression)argument;

          if (memberExpression.Expression is ParameterExpression)
               value = string.Format("<#= {0} #>", memberExpression.Member.Name);
          else
               value = GetValue(memberExpression);

          break;

     default:
          throw new InvalidOperationException("Unknown expression type!");
}

When the second paramenter values goes into the false part of the if statement it fails here:

value = GetValue(memberExpression);

..and gives the following error message which I have no idea what it is:

variable 'item' of type MyProject.ViewModels.GrantApplicationListViewModel' referenced from scope '', but it is not defined

Here is my view model:

public class GrantApplicationListViewModel
{
     public int Id { get; set; }
     public string FirstName { get; set; }
     public string LastName { get; set; }
     public string FullNameDisplay
     {
          get { return FirstName + " " + LastName; }
     }

     public DateTime CreatedDate { get; set; }

     public GrantApplicationStateType GrantApplicationStateType { get; set; }
}

Here is my partial grid declaration in my view:

@(Html.Telerik()
     .Grid<GrantApplicationListViewModel>()
     .Name("grdGrantApplications")
     .Columns(column =>
     {
          column.Bound(x => x.Id)
               .ClientTemplate(
                    "<label class=\"reference-number\"><a href=\"" + @Url.RouteUrl(Url.GrantApplicationDetails("<#= Id #>")) + "\">" + "<#= Id #>" + "</a></label>"
               )
               .Title("Ref #")
               .Width(70);

          column.Bound(x => x.FullNameDisplay)
               .Title("Owner")
               .Width(200);

          column.Bound(x => x.GrantApplicationStateType.Name)
               .Title("Status")
               .Width(90);

          //column.ActionLink("Edit", "Edit", "GrantApplication", item => new { id = item.Id });

          column.ActionLink("Open", "Edit", "GrantApplication", item => new { id = item.Id, applicationStateId = item.GrantApplicationStateType.Id });
     })
     .DataBinding(dataBinding => dataBinding.Ajax().Select("AjaxGrantApplicationsBinding", "Home"))
     .Pageable(paging => paging.PageSize(30))
     .TableHtmlAttributes(new { @class = "telerik-grid" })
)

What I am trying to achieve with the above is code is something to the effect of:

if grant application id  = 1

     then return Edit link and View link

else

     then return Details link

How would I do the above? Is the code in that article the only way to do it? Isn’t there a more simplar way? I did Google and couldn’t find much help on what I want to do. Has any one else come across something like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:21:59+00:00Added an answer on May 29, 2026 at 10:21 am

    If all you want is the client template to display different content based on the application id, it would be simpler to just put a conditional in the client template.

    column.Bound(x => x.Id)
      .ClientTemplate("<# if (Id == 1 ) { #> Edit Link and View Link <# } else { #> Details Link <# } #>");
    

    The Edit, View, and Details links would be put in the same way they are put in without the conditional.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the latest version of Telerik MVC controls on my ASP.NET MVC3
I am using the latest version of Telerik MVC with my ASP.NET MVC 3
I am using the latest version of Telerik MVC with ASP.NET MVC 3 and
I am using the latest version of Telerik MVC and ASP.NET MVC 3 with
I am using ASP.NET MVC 3 with razor and the latest version of the
I am using the latest version of jQuery and ASP.NET MVC 3 with the
I am using the latest version of protobuf-net with VS2008 integration. I have created
Using the latest version of EasyMock, I have a method that I need to
I'm using XAMPP (latest version) on OS 10.6.2, that's bundled with PHP 5.3.0 I
I am using the latest version of boost and boost.asio. I have this class:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.