我有一个从 xml/xslt 加载动态控件的列表视图
<asp:ListView ID="DynamicFields" runat="server"
DataSourceID="CustomFields"
OnItemDataBound="DynamicFields_ItemDataBound"
GroupItemCount="2" ItemPlaceholderID="itemsGroup"
GroupPlaceholderID="itemsGroup">
<LayoutTemplate>
<table width="470" border="0" cellpadding="0" cellspacing="10">
<asp:PlaceHolder ID="itemsGroup" runat="server" />
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<asp:PlaceHolder runat="server" ID="itemsGroup"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<custom:CustomField ID="Field" runat="server"
FieldIndex='<%# Eval("index") %>' />
</ItemTemplate>
<AlternatingItemTemplate>
<custom:CustomField ID="Field" runat="server"
FieldIndex='<%# Eval("index") %>' />
</AlternatingItemTemplate>
</asp:ListView>
在我的页面代码隐藏中,我正在绑定用户控件属性并调用加载 xml 并创建控件的绑定方法
protected void DynamicFields_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
ucCustomField uc = (ucCustomField)e.Item.FindControl("Field");
uc.FileName = FORM_PATH;
uc.FormName = FORM_NAME;
uc.LoadXMLFile(); //binding xml content here
}
}
我将此列表视图添加到具有静态控件和保存按钮的现有表单中。当我单击按钮时,它会导致验证并向我显示验证摘要弹出消息[预期],并且在我在弹出窗口中单击确定后,我在列表视图中的所有动态控件都会消失。如何保持这些控件可见以及回发后可能输入的任何值?