Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I had a problem while building search Web part based on Views.

I used codes to change the CAML query of the current view to make the Data List display the search result.
But when I submit the form (for searching), the view has been updated but there was nothing happened to the Data List until I reload or resubmit the form.

Here's my part of codes while submit button was clicked:
C#
SPWeb thisWeb = SPContext.Current.Web;
SPView view = thisWeb.Lists["listname"].Views["viewname"];
string querystring = //Generate the CAML query
view.Query = querystring;
view.Update();

I think the view did not load after my codes updated it.
Is there any way to make it updates immediately (I do not need to reload or resubmit the form)?

Thank you!
Posted

I got the solution.

Just simulate update view before submitting the form. You can use AJAX to solve this problem!

Thanks all!
 
Share this answer
 
You are only updating the view object which has nothing to do with what is displayed. The DataList being displayed needs to be refreshed so the updated view will be used.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900