I have a nestedGridTemplate which contains one object of a list.
this.Gridparent.MasterTableView.NestedViewTemplate = new Custom14NestedTemplate(this.model.Material.First());
This calls my class public class Custom14Template.
This class calls :
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);
}
Right now, my ascx contains only this :
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="View.ascx.cs" Inherits="*snip*.Templates.View" %>
hello there
Everything is displayed correctly
[grid start]
[item 1 : expanded]
hello there qty : 23.
[/item 1]
[item 2 /]
[item 3 /]
[/grid]
I’d like to pass my object to my ASCX, to build my html display from there using… The old equivalent of <%= html.EditorFor() %> (Asp.Net MVC). Instead of creating elements like my label and adding them to the container (building html in c# feels painful). Is that doable? How?
I adapted this answer to my need (no ICustomControl) :
The calling file contains the following :
The .ascx.cs was also modified a bit :
And the ascx just contains two plains, regulars asp:textbox (ID= product and production).