0

I am using this code in mVC2 and it is working Fine for me. But when i convert it into mvc3 this code give me error. Please tell me how i convert it into mvC3. The code is

<% Html.Grid(Model.MemberPagedList).Columns(column => {
 column.For(x => x.Id).Named("Id");
       column.For(x => x.message).Named("Message").Action(p =>
       { %>
       <td> some image tag here
       </td>
                     <td style="display: none; "  id =<%= p.Id%>>
                     <%= p.LogMessage  %>
                 </td>

                <% });
        }).RowStart((p,row)  => {     
             if (row.IsAlternate) { %>
                   <tr >
             <%  }  else  { %>
                 <tr>
             <% }
    }).Sort(Model.GridSortOptions).Attributes(@class => "table-list").Render(); %>

I am Replacing <% %> with @ But it is not working. I am not able to understand how i write Html Code ie <td>.....</td>

<td style="display: none;" id=<%= p.Id%>>
    <%= p.LogMessage  %>
</td> 

in mvc3

0

1 Answer 1

1

You could use a custom column to add an image to an MVCContrib Grid:

@(Html
    .Grid<MyViewModel>(Model.MemberPagedList)
    .Columns(column =>
    {
        column.For(x => x.Id);

        column.For(x => x.LogMessage);

        column
            .Custom(
                @<text>
                     <span>@item.LogMessage</span>
                     <img src="@Url.Action("image", new { id = item.Id })" alt="" />
                 </text>
            )
            .Named("Message");
    })
    .Sort(Model.GridSortOptions)
    .Attributes(new Hash(@class => "table-list"))
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.