Refreshing the Items in an XMLDataSource bound ASP.NET ListView

心不动则不痛 提交于 2019-12-13 03:59:25

问题


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.

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.

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.

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

Please help me out.


回答1:


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

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


来源:https://stackoverflow.com/questions/5857401/refreshing-the-items-in-an-xmldatasource-bound-asp-net-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!