0

テーブルがあり、データが入力されているかどうかを確認したいと思います。

以下に、グリッドを構築する方法と、ランタイム環境でどのように表示されるかを示しました。どのように行を数えますか?

グリッドの構築方法:

@using System.Dynamic
@{
    var result = new List<dynamic>();
    //Model.TrackingNumber = Model.RequestNumber.ToString();

    foreach (var proprow in Model.DDS)
    {
        var row = (IDictionary<string, object>)new ExpandoObject();
        Dictionary<string, object> eachPropRow = (Dictionary<string, object>)proprow;


        var fileName = proprow["Township"] + ", " + proprow["Erf"] + ", " + proprow["Portion"] + ", " + proprow["Property_Type"] + ", " + proprow["Unit"] + " " + "V?, " + DateTime.Now.ToString("(yyyy-MM-dd (HH.mm))"); //+ DateTime.Now.ToString("(yyyy-MM-dd (HH.mm))")
        foreach (KeyValuePair<string, object> keyValuePair in eachPropRow)
        {
            System.Web.HtmlString linkID;
            if (keyValuePair.Key == "Prop_ID")
            {

                linkID = Html.ActionLink(keyValuePair.Value.ToString(), "Valuation", new { PropID = keyValuePair.Value, Token = Model.Token, fileName, RequestNumber = Model.RequestNumber, ClientName = Model.ClientName, ReasonForValuation = Model.ReasonForValuation, ContactPerson = Model.ContactPerson, ContactNumber = Model.ContactNumber, Relation = Model.Relation, AccountNumber = Model.AccountNumber, BondAmount = Model.BondAmount, PurchasePrice = Model.PurchasePrice}, new { @class = "DownloadLink" });
                row.Add(keyValuePair.Key, linkID);
            }
            else
            {
                row.Add(keyValuePair);
            }
        }
        result.Add(row);
    }


    var grid = new WebGrid(result,null,null,30,false,false);

    @*@grid.GetHtml(tableStyle: "grid", headerStyle: "head", alternatingRowStyle: "alt");*@

    @grid.GetHtml(
       tableStyle: "grid",
       headerStyle: "grid-header",
       alternatingRowStyle: "grid-alternating-row", //grid-alternating-row
       selectedRowStyle: "grid-selected-row",
       rowStyle: "grid-row-style"

       )

  }

以下に、ランタイムコンソールに表示されるテーブルをリストしました。

<table class="grid">
    <thead>
        <tr class="grid-header"><th scope="col">Prop_ID</th>
            <th scope="col">Erf</th>
            <th scope="col">Street</th>
            <th scope="col">Unit</th>
            <th scope="col">Portion</th>
            <th scope="col">Size</th>
            <th scope="col">Suburb</th>
            <th scope="col">Township</th>
            <th scope="col">Province</th>
            <th scope="col">Property_Type</th>
            <th scope="col">Owner</th>
            <th scope="col">Title_Deed_No</th>
            <th scope="col">Purch_Price</th>
            <th scope="col">Purch_Date</th>
        </tr>
    </thead>
    <tbody>
        <tr class="grid-row-style">
            <td><a class="DownloadLink" href="/ReturnProperties/Valuation?PropID=14351160&amp;Token=f7a9d22c-ce87-45df-a8b1-a05bdba9e068&amp;fileName=HIGHVELD%20EXT%207%2C%201402%2C%200%2C%20FH%2C%20%20V%3F%2C%20(2013-07-15%20(14.53))&amp;RequestNumber=45735864378386V1">14351160</a></td>
            <td>1402</td>
            <td>77 SANTA MONICA</td>
            <td></td>
            <td>0</td>
            <td>750</td>
            <td>CENTURION GOLF ESTATE</td>
            <td>HIGHVELD EXT 7</td>
            <td>GA</td>
            <td>FH</td>
            <td>MOSSOP MAUREEN</td>
            <td>T101413/2007</td>
            <td>4800000</td>
            <td>20070611</td>
        </tr>
        <tr class="grid-alternating-row">
            <td><a class="DownloadLink" href="/ReturnProperties/Valuation?PropID=14351160&amp;Token=f7a9d22c-ce87-45df-a8b1-a05bdba9e068&amp;fileName=HIGHVELD%20EXT%207%2C%201402%2C%200%2C%20FH%2C%20%20V%3F%2C%20(2013-07-15%20(14.53))&amp;RequestNumber=45735864378386V1">14351160</a></td>
            <td>1402</td>
            <td>77 SANTA MONICA</td>
            <td></td>
            <td>0</td>
            <td>750</td>
            <td>CENTURION GOLF ESTATE</td>
            <td>HIGHVELD EXT 7</td>
            <td>GA</td>
            <td>FH</td>
            <td>MOSSOP IAN PAUL</td>
            <td>T101413/2007</td>
            <td>4800000</td>
            <td>20070611</td>
        </tr>
    </tbody>
    </table>
4

2 に答える 2