我正在執行ITemplate
接口的ListView
控件。如果我在我的自定義類中實現ItemTemplate
,那麼一切都會好的。我的意思是,運行時會調用InstantiateIn當我使用ITemplate,離開InstantiateIn(控制容器)的原因
ListView.ItemTemplate = new CustomClass();
CustomClass :ITemplate
{
public void InstantiateIn(Control container)
{
HtmlTable table = CreateHeader();
container.Controls.Add(table);
}
...
}
但我想要做同樣的ListView.LayoutTemplate
。在這種情況下,運行時只調用一次InstantiateIn,但每次下一次更新都會離開我的方法。這是什麼原因?
點擊不同的按鈕後,我必須更改我的LayoutTemplate。 而我的LayoutTemplate具有整個ListView的標題。我必須改變它,這取決於按鈕。此外,我有兩個自定義類與ITemplate的實現(一個用於ItemTemplate和一個用於LayoutTemplate)。我將認識到以下行爲: 1)。如果我點擊Button1 ListView.ItemTemplate = new CustomItemClass1(); ListView.LayoutTemplate = new CustomLayuotClass1();如果我點擊按鈕2 ListView.ItemTemplate = new CustomItemClass2(); ListView.LayoutTemplate = new CustomLayuotClass2(); – Konstantin 2011-03-15 13:08:09
你是否在Load事件中執行此操作?不足以在ListView上擁有不同的CSS樣式? – Robert 2011-03-15 13:32:58