iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
My webgrid is bound to the ISDataSource. I set EnableCaching to Yes on the ISDataSource. I have a dropdown list. I want to refresh the webgrid with the new data when the list selection is changed on a Flypostback. I call the wg.Refresh() in my srcript. But the webgrid is filled with the cached data. It doesn't call the SelectMethod in ISDataSource. Is there a way to clear ISDataSource cache on the client side?
The attached is a working sample. Please check TestCachingForm.
Thanks!
There is a workaround to achieve your scenario.
First, you need to have a flag that tells whether ISDataSource cache needs to be cleared or not. Since you need to have ISDataSource cache to be cleared when the year list selection is changed, the flag can be set in _fiscalYearList_onchange client side event.
After set the flag, it has to be sent to server side (before refresh WebGrid) where we can clear the ISDataSource cache based on this parameter. It can be send by using “AddInput” method of WebGrid.
<script language="javascript" type="text/javascript"> <!-- function _fiscalYearList_onchange() { var wg = ISGetObject('_webGrid'); var ClearCachedData = "1"; wg.AddInput("NeedClearCachedData", ClearCachedData); wg.Refresh(); } --> </script>
Later, on Page_Load event we can retrieve the parameter and clear ISDataSource cache where the condition is met.
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { _fiscalYearList.Items.Add("2009"); _fiscalYearList.Items.Add("2008"); _fiscalYearList.Attributes["onchange"] = "return _fiscalYearList_onchange()"; } string NeedClearCachedData = string.IsNullOrEmpty(Request.Form["NeedClearCachedData"]) ? "" : Request.Form["NeedClearCachedData"]; if (NeedClearCachedData == "1") ISDataSource1.Tables[0].ClearCache(); }
I modify your sample to use dsNorthwind dataset that available in WebGridSamples project and tried to reproduce the issue based on your sent sample, but I was unable to replicate the issue on my end.
Please have the attached sample tested on your end and let me know your response.
Maybe I didn't explain the problem clear enough. I have a ISDataSource which is using CustomObject. Its SelectMethod is set to "GetLeaseActivity" which is in TestIntersoft.UI.DataLayer. You have to set a Breakpoint inside function GetLeaseActivity and debug to it. GetLeaseActivity will only get called once for the same year. For example, I selected 2009 and then 2008, and then 2009 again. GetLeaseActivity function only get called at first time I selected 2009 or 2008, not on the seconde time I select 2009.
On your sample, there is no way I can check if the SelectMothed got called on the second time.
Please try to clear the session in OnInitializeLayout of WebGrid event, as shown below.
protected void _webGrid_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e) { HttpContext.Current.Session.Clear(); }
Please let me know whether this helps or not.
No, this does not help. It's doing the same thing. Besides I don't want to clear the session-state collection. Is there a way to just clear the ISDataSource Caching on client side or server side? My orginal attachement is a working sample, you can test the TestCachingForm to see if it works or not.
I’ve been able to run your sent sample on my end. I’m sorry for the inconvenience if I didn’t understand your issue very well.
When you enable caching on ISDataSource, GetLeaseActivity function only gets called at first time. In order to have the GetLeaseActivity function called on the second time and so on, you can simply set EnableCaching property of ISDataSource to “no” value.
Should you have any specific reasons that you should use “EnableCaching” and clear ISDataSource caching at the same time, please let us know.
I use "EnableCaching", so when I do Sort or Filter on the Grid, Select Method retrieve the data from the cache rather than from business object that associated with it.
But I when I change the Year selection from the dropdown list, I want the refreshed data from the business object (from database). Because the data may be changed. That's why I want to clear the ISDataSource cache when the year list selection is changed.
If I don't use ISDataSource for the data binding, with AllowAutoDataCaching property on grid set to True, webgrid.Refresh() will make _webGrid_InitializeDataSource called again where retrieve the data from business object. Can the ISDataSource behave the same way?
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname