在刷新将XmlDataSource绑定ASP.NET ListView中的项目绑定、项目、XmlDataSource、ASP

2023-09-07 16:57:36 作者:远镇

我有一个页面上的ASP.NET ListView控件,它势必将XmlDataSource。 当我改变数据源的数据,在ListView的onItemDataBound事件被称为和ListViewItemEventArgs对象包含被绑定到列表视图的第一时间的项目。

I have a ASP.NET ListView control on a page and it is bound to an XMLDataSource. When i change the data in the DataSource, the onItemDataBound event of the ListView is called, and the ListViewItemEventArgs object contains the items that were bound to the listview the very first time.

我无法刷新列表视图的内容。这仍然存在我离开页面,回来后即使经过。考虑到其新的Page_Load,我不明白为什么ListView中仍然包含旧数据。

I am unable to refresh the content of the listview. This persists even after I leave the page and come back later. Considering its a fresh page_Load, i can't understand why the ListView still contains old data.

该方案是: XML包含2种不同类型的项目。在点击Type1和浏览器导航到列表视图,1型的项目被绑定到的XmlDataSource和ListView控件加载。

The scenario is: The xml contains items of 2 different types. On clicking Type1, the browser navigates to the listview, the items of type 1 are bound to the XmlDataSource and the ListView is loaded.

同样为2型,但列表视图只会显示被囚的第一次数据。

Same for type2, but the listview will only show the data that was bound the first time.

请帮我了。

推荐答案

在默认情况下缓存是对的XmlDataSource。尝试将其关闭:

By default caching is on for the XmlDataSource. Try turning it off:

 <asp:XmlDataSource ID="XmlDataSource1" runat="server" EnableCaching="False">
 </asp:XmlDataSource>