我的 aspx 文件中有一个使用 ActionSyntax 的代码,我想改用 GridModel,但我不知道该怎么做。
这是我的 aspx 文件的示例:
<% Html.Grid(ViewData.Model).Columns(column => {
column.For(x => x.Id).Named("N° de contrat");
column.For(x => x.SubscriptionDate).Format("{0:d}").Named("Date de souscription");
column.For(x => x.SubscriptionOrigin).Named("Source");
column.For(x => x.Agent).Named("Agence(*)");
column.For(x => x.Agent).Named("Agent");
column.For(x => x.Subscriber).Named("Souscripteur");
column.For(x => x.ProductTitle).Named("Produit");
column.For(x => x.NbBeneficiaries).Named("Nombre de bénéficiaires");
column.For(x => x.Price).Named("Montant du contrat");
column.For("PDF").Named("").Action(p => {%> <td><img src="../Content/Images/pdf.gif" /></td> <%});
column.For("Mail").Named("").Action(p => {%> <td><img src="../Content/Images/mail.gif" /></td> <%});
column.For("Attestation").Named("").Action(p => {%> <td><img src="../Content/Images/attestation.gif" /></td> <%});
column.For("Poubelle").Named("").Action(p => {%> <td><img src="../Content/Images/poubelle.png" /></td> <%});
}).Attributes(id => "subList").Render(); %>
我想做:
<%= Html.Grid(ViewData.Model).WithModel(new MyGridModel()) %>
但我不知道如何在 .cs 文件中呈现此 ActionSyntax 部分:
column.For("PDF").Named("").Action(p => {%> <td><img src="../Content/Images/pdf.gif" /></td> <%});
column.For("Mail").Named("").Action(p => {%> <td><img src="../Content/Images/mail.gif" /></td> <%});
column.For("Attestation").Named("").Action(p => {%> <td><img src="../Content/Images/attestation.gif" /></td> <%});
column.For("Poubelle").Named("").Action(p => {%> <td><img src="../Content/Images/poubelle.png" /></td> <%});
有人知道吗?
谢谢。