0
如何讓_dynamicMaterials清空或清除視圖狀態?清除動態UserControl容器
當用戶點擊提交我想重置容器,所以所有的文本框都是空的。
任何想法如何能解決這個問題?
private materials[] _dynamicMaterials; // Container for dynamically added UserControl "materials.ascx"
protected void Page_PreInit(object sender, EventArgs e)
{
GetPostBackControl(Page);
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (!this.DesignMode)
{
int count = MySession.Current.UserControlCount;
_dynamicMaterials = new materials[count];
for (int i = 0; i < count; i += 1)
{
Control newcont = LoadControl("materials.ascx");
newcont.ID = "materialControl" + i.ToString();
myPlaceHolder1.Controls.Add(newcont);
_dynamicMaterials[i] = (materials)newcont;
}
}
}
您是否嘗試過'ViewState.Clear();'? http://msdn.microsoft.com/en-us/library/system.web.ui.statebag.clear.aspx – 2012-04-02 21:14:46
ViewState.clear();不起作用。 – 2012-04-02 21:23:52