none
[Help] Updating view does not affect while submitting form

    שאלה

  • 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:

    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!

    • נערך על-ידי Khoi, Doan Quang יום שני 26 מרץ 2012 10:37 Demo code
    יום שני 26 מרץ 2012 10:34

תשובות

  • Hi Khoi,

    I can reproduce the issue, the page needs to be refreshed or resubmit the form. The issue seems to be that when execute the click event, refresh the page, the list form is refreshed by default.

    In this situation, please go to SharePoint list page, go to Site Actions->Edit page, choose the list view web part, edit the web part, in the web part editing dialog, AJAX Options, check “Enable Asynchronous Load”.

    Or you can try to use code to refresh the page in click event, like this:
    Context.Response.Redirect(Context.Request.Url.AbsoluteUri);

    Thanks,
    Qiao


    Qiao Wei

    TechNet Community Support

    • סומן כתשובה על-ידי Khoi, Doan Quang שבת 31 מרץ 2012 08:39
    יום חמישי 29 מרץ 2012 08:59
    מנחה דיון

כל התגובות

  • Hi Khoi,

    I can reproduce the issue, the page needs to be refreshed or resubmit the form. The issue seems to be that when execute the click event, refresh the page, the list form is refreshed by default.

    In this situation, please go to SharePoint list page, go to Site Actions->Edit page, choose the list view web part, edit the web part, in the web part editing dialog, AJAX Options, check “Enable Asynchronous Load”.

    Or you can try to use code to refresh the page in click event, like this:
    Context.Response.Redirect(Context.Request.Url.AbsoluteUri);

    Thanks,
    Qiao


    Qiao Wei

    TechNet Community Support

    • סומן כתשובה על-ידי Khoi, Doan Quang שבת 31 מרץ 2012 08:39
    יום חמישי 29 מרץ 2012 08:59
    מנחה דיון
  • Hi Khoi,

    I can reproduce the issue, the page needs to be refreshed or resubmit the form. The issue seems to be that when execute the click event, refresh the page, the list form is refreshed by default.

    In this situation, please go to SharePoint list page, go to Site Actions->Edit page, choose the list view web part, edit the web part, in the web part editing dialog, AJAX Options, check “Enable Asynchronous Load”.

    Or you can try to use code to refresh the page in click event, like this:
    Context.Response.Redirect(Context.Request.Url.AbsoluteUri);

    Thanks,
    Qiao


    Qiao Wei

    TechNet Community Support

    Thanks for your support!

    KhoiDQ

    שבת 31 מרץ 2012 08:39