リストの1つのオブジェクトを含むネストされたGridTemplateがあります。
this.Gridparent.MasterTableView.NestedViewTemplate = new Custom14NestedTemplate(this.model.Material.First());
これは私のクラスを呼び出しますpublic class Custom14Template
。
このクラスは次を呼び出します。
public void InstantiateIn(System.Web.UI.Control container)
{
var myPage = new Page();
Control c = myPage.LoadControl("~/Custom14/Templates/View.ascx");
container.Controls.Add(c);
var x = new Label();
x.Text = string.Format("qty : {0}.<br />", this.MyMaterial.Quantity);
container.Controls.Add(x);
}
現在、私のascxにはこれだけが含まれています:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="View.ascx.cs" Inherits="*snip*.Templates.View" %>
hello there
すべてが正しく表示されます
【グリッドスタート】 [項目 1 : 拡張] こんにちは数量: 23。 [/項目 1] 【項目2/】 【項目3/】 [/グリッド]
オブジェクトを ASCX に渡し、そこから HTML ディスプレイを構築したいと思います... (Asp.Net MVC)に相当する古いものです。<%= html.EditorFor() %>
ラベルのような要素を作成してコンテナーに追加する代わりに (C# で html を作成するのは面倒です)。それは可能ですか?どのように?