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

[Solved] Error adding Columns to a Grid

2 Answers 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
IQworks
Top achievements
Rank 1
IQworks asked on 07 Feb 2010, 02:00 PM
Hi, 
    When i run this I get no errors and it runs as desired ..... 
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<BCAnalytics.Models.Company>>" %> 
    <% Html.Telerik()  
           .Grid(Model)  
           .Name("Companies")  
           .PrefixUrlParameters(false)  
           .Columns(columns => 
                    {  
                        columns.Add(c => 
                                    {  
                                        %> 
                                            <%= Html.ActionLink("Edit", "Edit", new { id = c.coCompanyNo })%> 
                                            <%= Html.ActionLink("Delete", "Delete", new { id = c.coCompanyNo })%> 
                                        <%  
                                    }).Title("Action");  
 
                        columns.Add(c => c.coMemberNo).Width(20);  
                        columns.Add(c => c.coCompanyNo);  
                        columns.Add(c => c.coCompanyName);  
                        columns.Add(c => c.coContact);  
                        columns.Add(c => c.coEmail);  
                        columns.Add(c => c.coGroupCode);  
                     })  
            .Filterable()  
            .Sortable(sort => sort.SortMode(GridSortMode.MultipleColumn))  
            .Pageable()  
            .Scrollable(scrolling => scrolling.Height(200))  
            .Render(); %> 
    <p><%= Html.ActionLink("Create New", "Create") %></p

    When i run this i get no errors and it runs as desired with ajaxbinding ... 
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<BCAnalytics.Models.CompanyVM>>" %> 
     
        <%= Html.Telerik().Grid(Model)  
              .Name("CompanyGrid")  
              .Columns(columns => 
                {  
                    columns.Add(o => o.cMemberNo).Width(20);  
                    columns.Add(o => o.cCompanyNo).Width(20);  
                    columns.Add(o => o.cCompanyName).Width(50);  
                    columns.Add(o => o.cEmail).Width(50);  
                    columns.Add(o => o.cGroupCode).Width(50);  
                    columns.Add(o => o.cDateCreated).Format("{0:MM/dd/yyyy}").Width(50);  
                })  
               .Ajax(settings => settings.Action("_AjaxBindingCompany", "Company"))  
               .Pageable()  
               .Sortable()  
               .Scrollable()  
               .Filterable()  %> 
   <p><%= Html.ActionLink("Create New", "CompanyCreate") %></p

   But when i add columns to this I get errors .... 
  
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<BCAnalytics.Models.CompanyVM>>" %> 
     
        <%= Html.Telerik().Grid(Model)  
              .Name("CompanyGrid")  
              .Columns(columns => 
                {  
                    columns.Add(c => 
                                  {  
                                        
                                        %> 
                                            <%= Html.ActionLink("Edit", "CompanyEdit", new { id = c.cCompanyNo })%> 
                                            <%= Html.ActionLink("Delete", "CompanyDelete", new { id = c.cCompanyNo })%> 
                                        <%  
            }).Title("Action");  
 
 
                    columns.Add(o => o.cMemberNo).Width(20);  
                    columns.Add(o => o.cCompanyNo).Width(20);  
                    columns.Add(o => o.cCompanyName).Width(50);  
                    columns.Add(o => o.cEmail).Width(50);  
                    columns.Add(o => o.cGroupCode).Width(50);  
                    columns.Add(o => o.cDateCreated).Format("{0:MM/dd/yyyy}").Width(50);  
                })  
               .Ajax(settings => settings.Action("_AjaxBindingCompany", "Company"))  
               .Pageable()  
               .Sortable()  
               .Scrollable()  
               .Filterable();  %> 
   <p><%= Html.ActionLink("Create New", "CompanyCreate") %></p

I get this error with line 10 highlighted ? .... 
Server Error in '/' Application.  
--------------------------------------------------------------------------------  
 
Compilation Error   
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.   
 
Compiler Error Message: CS1525: Invalid expression term ')'  
 
Source Error:  
 
   
 
Line 6:                  {  
Line 7:                      columns.Add(c => 
Line 8:                                    {  
Line 9:                                          
Line 10:                                         %> 
   
 
   Not sure what I am doing wrong ?
   Thanks for your time
  

2 Answers, 1 is accepted

Sort by
0
James Davies
Top achievements
Rank 1
answered on 07 Feb 2010, 03:44 PM
Dear IQWorks,

I'm not sure, but could it be this issue - http://www.telerik.com/community/forums/aspnet-mvc/grid/no-support-for-ajax-delete.aspx#996881 ?

    Regards,
    Jim
0
IQworks
Top achievements
Rank 1
answered on 07 Feb 2010, 04:08 PM
 Thanks James, that worked well.
Tags
Grid
Asked by
IQworks
Top achievements
Rank 1
Answers by
James Davies
Top achievements
Rank 1
IQworks
Top achievements
Rank 1
Share this question
or