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

Cannot implicitly convert type 'void' to 'object'

1 Answer 641 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.
Gaurav
Top achievements
Rank 1
Gaurav asked on 04 May 2012, 02:05 AM
Hi All, 
Following is the *.aspx page, where I get compiler error 'Cannot implicitly convert type 'void' to 'object'' just by calling '.Render();' in Html.Telerik().Grid<.... Please note that this page is strongly bound to the order object which has orderLines collection. Any help to fix this would be appreciated.
 
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<WebSite.Models.Order>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Details
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>Details</h2>
  
<fieldset>
    <legend>Order</legend>
    <div class="display-label">
        <%: Html.LabelFor(model => model.Number)%>
    </div>
    <div class="editor-field">
        <%: Html.TextBox("txtNum",Model.Number, new Dictionary<string, object>() { { "readonly", "true" }, { "Enabled", "false" } })%>
    </div>
</fieldset>

   <%:        
    Html.Telerik().Grid<WebSite.Models.OrderLine>("orderLines")
               .Name("grdOrderLines")
               .Columns(c => c.Bound(o => o.Product))
               .Columns(c => c.Bound(o => o.TotalCost))
               .PrefixUrlParameters(false) 
               .Pageable()
               .Sortable()
               .Filterable()
               .Groupable()
               .Render();
    %>

</asp:Content>

1 Answer, 1 is accepted

Sort by
0
Pechka
Top achievements
Rank 1
answered on 04 May 2012, 07:19 AM
Hello


<%: %> is the encoded rendering method (do not call render)
<%= %> renders result to the output - (do not call render)
<% %> executes the code - here you should use the render method

more information here http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx 
Tags
Grid
Asked by
Gaurav
Top achievements
Rank 1
Answers by
Pechka
Top achievements
Rank 1
Share this question
or