0

このグリッドビューをかみそりの構文で変換するにはどうすればよいですか? (data => { %>) の中に中括弧がありますか?

<%Html.GridView<Employee>(
      Model,
      data => { %>
        <table class="grid" cellpadding="0" cellspacing="0">
            <tr>
                <th>&nbsp;</th>
                <th>&nbsp;</td>
                <th>&nbsp;</td>
                <th>Name</th>
                <th>E-mail</th>
            </tr>
      <% },
      (item, css) => { %>
        <tr class="<%=css%>">
            <td><%=Html.ActionImage("Edit", "Home", new { Id = item.Id }, "~/Content/edit.gif", "Edit")%></td>
            <td><%=Html.ActionImage("Delete", "Home", new { Id = item.Id }, "~/Content/delete.gif", "Delete")%></td>
            <td>&nbsp;</td>
            <td><%=item.Name%></td>
            <td><%=item.Email%></td>
        </tr>
      <% },
      "item",
      "item-alternating",
      item => { %>
        <%using (Html.BeginForm("Save", "Home", new { Id = item.Id }, FormMethod.Post, new { id = "editForm" })) {%>
            <tr class="item-edit">
                <td><input type="image" runat="server" id="save" src="~/Content/ok.gif" alt="Update" /></td>
                <td><%=Html.ActionImage("Index", "Home", null, "~/Content/cancel.gif", "Cancel")%></td>
                <td>&nbsp;</td>
                <td><%=Html.TextBox("Name", item.Name)%></td>
                <td><%=Html.TextBox("Email", item.Email)%></td>
            </tr>
        <% } %>
      <% },
      data => { %> 
            <tr>
                <td colspan="5"><hr /></td>
            </tr>       
            <tr class="paging">      
                <td colspan="5">
                    <% if (data.PagedList.IsPreviousPage) { %>
                        <%=Html.ActionImage("Show", "Home", new { page = data.PagedList.PageIndex - 1 }, "~/Content/previous.gif", "Previous page")%>
                    <% } %>

                    <%=data.PagedList.TotalCount.ToString()%> records

                    <% if (data.PagedList.IsNextPage) { %>
                        <%=Html.ActionImage("Show", "Home", new { page = data.PagedList.PageIndex + 1 }, "~/Content/next.gif", "Next page")%>
                    <% } %>
                </td>
            </tr>  
            <tr>
                <td colspan="5">&nbsp;</td>
            </tr>
            <%using (Html.BeginForm("Add", "Home", FormMethod.Post, new { id = "addForm" })) {%>
                <tr>
                    <th>&nbsp;</th>
                    <th>&nbsp;</td>
                    <th>&nbsp;</td>
                    <th>Name</th>
                    <th>E-mail</th>
                </tr>
                <tr>
                    <td><input type="image" runat="server" id="add" src="~/Content/add.gif" alt="Add" /></td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td><%=Html.TextBox("Name", "")%></td>
                    <td><%=Html.TextBox("Email", "")%></td>
                </tr>
            <% } %>  
            </tr>
        </table>
      <% });%>
4

1 に答える 1

0

Razor は括弧を記号<% ... %>だけに置き換えます。@たとえば、この行

<%=Html.TextBox("Email", "")%>

になる

@Html.TextBox("Email", "")

基本的にはそれだけです。<% ... %>すべてのブラケットを削除するだけです。

于 2012-11-12T19:17:34.853 に答える