私は別のユーザーによって作成されたアプリケーションを持っていて、ASPXドキュメント内のC#を使用してテーブルからデータをバインドするように見えてきた機能を、バインド前のインラインC#ifステートメント
ここは、彼がデータをバインドするように見えるコードです:
<table class="device_edit_device_table">
<tr>
<th><%: Resources.UserEditUserControlDevicesSerialNumber %></th>
<th><%: Resources.UserEditUserControlDevicesCountry %></th>
<th><%: Resources.UserEditUserControlDevicesSoftwareVersion %></th>
<th><%: Resources.UserEditUserControlDevicesPlatform %></th>
<th><%: Resources.UserEditUserControlDevicesCompany %></th>
<th><%: Resources.UserEditUserControlDevicesPurchaseDate %></th>
<th><%: Resources.UserEditUserControlDevicesPurchaseLocation %></th>
<th><%: Resources.UserEditUserControlDevicesRegistrationDate %></th>
<th><%: Resources.UserEditUserControlDevicesDeviceType %></th>
<th><%: Resources.UserEditUserControlDevicesPreOwned %></th>
<th>Lost</th>
<th>Stolen</th>
<th style="width:200px">Admin Comments</th>
<th>Edit Device</th>
<th>Edit Device Registration</th>
<th>De-register Device</th>
</tr>
<tr>
<td><%: Model.Unit.SerialNumber ?? string.Empty %></td>
<td><%: Model.Unit.UnitCountry.Country ?? string.Empty%></td>
<td><%: Model.Unit.UnitSoftwareVersion.Version ?? string.Empty%></td>
<td><%: Model.Unit.UnitPlatform.Name ?? string.Empty%></td>
<td><%: Model.Unit.UnitCompany.Name ?? string.Empty%></td>
<td><%: Model.PurchaseDate.ToString() %></td>
<td><%: Model.PurchaseLocation ?? string.Empty%></td>
<td><%: Model.RegistrationDate.ToShortDateString()%></td>
<td><%: Model.Unit.UnitBundle.Bundle %></td>
<td><%: Model.Unit.IsSecondHand ? Resources.UserEditUserControlDevicesPreOwnedYes : Resources.UserEditUserControlDevicesPreOwnedNo %></td>
<td><%: Model.Unit.Lost ?? false ? "Yes" : "No"%></td>
<td><%: Model.Unit.Stolen ?? false ? "Yes" : "No"%></td>
<td style="width:200px"><%: Model.Unit.Comments%></td>
<td><%: Html.ActionLink("Edit Device", "Edit", "Unit", new { id = Model.SerialID, redirectTo = "DeviceDetailsPage" }, null)%></td>
<td><%: Html.ActionLink("Edit Device Registraion", "Edit", "Registration", new { id = Model.RegistationID, redirectTo = "DeviceDetailsPage" }, null)%></td>
<td><%: Html.ActionLink("De-register", "Deregister", "Device", new { id = Model.RegistationID }, null)%></td>
</tr>
今、このページには、Inherits="System.Web.Mvc.ViewPage<Satmap.RouteShare.Web.Models.DeviceRegistration>"
を持っていますが、私はそれが指す考える理由であるクラスDeviceRegistration
を見つけるように見えることはできませんデータベーステーブル
私は最近「削除済み」データベースに列を追加しました。これが真であれば、その行をバインドする必要はありません。とにかく私はDeviceRegistration
のこの削除された列を確認することができますし、その本当のデータを読み込まない場合は?あなたがデータベースに列を追加したい場合は、あなたがする必要があります
<%: if(!Model.Removed) { %>
<tr>
<td><%: Model.Unit.SerialNumber ?? string.Empty %></td>
<td><%: Model.Unit.UnitCountry.Country ?? string.Empty%></td>
<td><%: Model.Unit.UnitSoftwareVersion.Version ?? string.Empty%></td>
<td><%: Model.Unit.UnitPlatform.Name ?? string.Empty%></td>
<td><%: Model.Unit.UnitCompany.Name ?? string.Empty%></td>
<td><%: Model.PurchaseDate.ToString() %></td>
<td><%: Model.PurchaseLocation ?? string.Empty%></td>
<td><%: Model.RegistrationDate.ToShortDateString()%></td>
<td><%: Model.Unit.UnitBundle.Bundle %></td>
<td><%: Model.Unit.IsSecondHand ? Resources.UserEditUserControlDevicesPreOwnedYes : Resources.UserEditUserControlDevicesPreOwnedNo %></td>
<td><%: Model.Unit.Lost ?? false ? "Yes" : "No"%></td>
<td><%: Model.Unit.Stolen ?? false ? "Yes" : "No"%></td>
<td style="width:200px"><%: Model.Unit.Comments%></td>
<td><%: Html.ActionLink("Edit Device", "Edit", "Unit", new { id = Model.SerialID, redirectTo = "DeviceDetailsPage" }, null)%></td>
<td><%: Html.ActionLink("Edit Device Registraion", "Edit", "Registration", new { id = Model.RegistationID, redirectTo = "DeviceDetailsPage" }, null)%></td>
<td><%: Html.ActionLink("De-register", "Deregister", "Device", new { id = Model.RegistationID }, null)%></td>
</tr>
<%: } %>
:if節
あなたの最初の問題のような音は、そのDeviceRegistrationモデルを見つけることですか?あなたが 'DeviceRegistration'のためのあなたの解決策でfindallをすれば、他の何かを見つけることはありませんか?また、すでに「DeviceRegistration」テーブルにcolを追加している場合は、単にビューにアクセスしようとしましたか? – mmcrae