0
からデータを取得することができ
私はまた、私は、このコードでは、内側の追加クラステーブルとして参加することができますどのようにないが、コントローラ
public ActionResult StudentDashboard(int? page)
{
ViewBag.StudentRequest = GetData.Tables[0].AsEnumerable().Select(t => new
{
StudentRequestId = t.Field<int>("StudentRequestId"),
ClassName = t.Field<string>("ClassName"),
CreatedOn = t.Field<DateTime>("CreatedOn"),
Location = t.Field<string>("Location"),
PaymentMethod = t.Field<string>("PaymentMethod"),
}).ToList().ToPagedList(page ?? 1,1);
return View(db.StudentRequests.Where(x => x.RegistrationId == registrationid).ToList().ToPagedList(page ?? 1, 3));
}
としてデータを返していますように私のコントローラのコードはありますか?
db.StudentRequests.Where(x => x.RegistrationId == registrationid)
.ToList()
.ToPagedList(page ?? 1, 3)
とビュー側の私は
私が取得することはできませんよどのように私はこのコードを@Html.LabelFor(model => model.First().StudentRequestId)
ではなく、テキストのみのStudentRequestId
レコードを取得することができます
@using PagedList;
@using PagedList.Mvc;
@model IPagedList<Student_Tutor.Models.StudentRequest>
@if (ViewBag.StudentRequest != null)
{
var StudentRequestId = (int)Model.First().StudentRequestId;// Here I am able to get the StudentRequestId
var StudentRequestTimecount = StudentRequestTime.Where(d => d.StudentRequestId == StudentRequestId).ToList();
var TutorStudentRequestcount = TutorStudentRequest.Where(d => d.StudentRequestId == StudentRequestId).ToList();
@Html.LabelFor(model => model.First().StudentRequestId)// here only text is displaying as StudentRequestId
@Html.DisplayNameFor(Model => Model.First().CreatedOn)//here only text is diplaying as created on
}
ようなコードを書かれています番号の代わりにStudentRequestId
のID番号は、ビュー側がテキストのみを表示しています。
このスクリーンショットを参照してください:それは財産を飾るために使用された場合
私も用ディスプレイを使用してみましたが、それでも、それは私があまりにも上に作成しますが、 'StudentRequestId'が有効な値では、' DisplayForを持っている場合は、それが唯一の – Xtremcool
を示しました。 'ヘルパーはそれをレンダリングします。 – Xtremcool
テキストを示しているためにしようとした同じテキスト – Shyju