locked
Refresh Gridview closing dialog RRS feed

  • Question

  • Hi guys,

    i have one grid which is filled with records coming from list. To add new item i am using NewForm of List afer closing my gridview is not refreshing how can i refresh grid as well as i can see new added item 

    for closing popup im using following script which is working fine

    ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", @"window.frameElement.commitPopup();", true);


    Regards DILDAR-SharePoint Developer

    Tuesday, January 22, 2013 1:10 PM

All replies

  • I've done this in a couple projects by issuing a DataBind for the gridview in the Page_Load method if its a PostBack.  Closing the dialog will generate a postback to the page.  I've never found a way to do it in pure javascript.

    Paul Stork SharePoint Server
    MVP Principal Solutions Architect: BlueChip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    • Marked as answer by Jack-Gao Friday, January 25, 2013 8:58 AM
    • Unmarked as answer by Dildar.ali Friday, January 25, 2013 5:27 PM
    Tuesday, January 22, 2013 1:19 PM
  • Hi, Paul stork,

    you mean to say their is no solution this is not valid answer. 


    Regards DILDAR-SharePoint Developer

    Friday, January 25, 2013 1:29 PM
  • Not quite.  I mean to say that I haven't found a way to tell the page to refresh in JavaScript on the client.  The grid has to be refreshed in server side code.  The easiest way I've found to do that is by re-binding the grid when the page is posted back.  The javascript code mentioned above will do a postback.  But you have to put code in the page load event that refreshes the grid on postback or when the page refreshes the grid doesn't. 

    Paul Stork SharePoint Server
    MVP Principal Solutions Architect: BlueChip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    Friday, January 25, 2013 4:02 PM
  • Parent page can be refresh by following javascript

    CloseButton.Attributes.Add("onclick", "return windowclose();");   ClientScript.RegisterStartupScript(GetType(), "CloseScript", "window.opener.location.reload(); window.close();", true);

    when i use above method as DotNet Page it works fine parent page refresh and child popup closed. But when i use same script in SharePoint PopUp what happen page refresh but not parent. child page refreshed and not closed that is not correct i want to refresh parent page at the time of closing child Pop up. Well i am trying to find if i get i will post and if you get any script before me than you post :)





    Regards DILDAR-SharePoint Developer

    Friday, January 25, 2013 5:26 PM
  • Hi,

    You can use SP.UI.ModalDialog.RefreshPage at the callback function.

    It will refresh the parent page.

    Tuesday, January 29, 2013 10:38 AM
  • i applied it but not working can u send me script.. where i put at Child Page or Parent Page

    Regards DILDAR-SharePoint Developer

    Tuesday, January 29, 2013 10:54 AM
  • Refreshing the page won't refresh (rebind) the gridview unless you do something when the page refreshes to rebind it.  That's why I include a databind in the page_Load method on postback.  Remember, depending on the code on the page refreshing the page and rebinding the gridview may not be the same thing.

    Paul Stork SharePoint Server
    MVP Principal Solutions Architect: BlueChip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    Tuesday, January 29, 2013 2:49 PM
  • I hope you must have opening the new form in a modal dialog using ShowModalDialog. So when you do this you can have dialogReturnValueCallback funtion as below. In that function you can do window.location.href=window.location.href.

    functionModalDialog(FormPath, FormWidth, FormHeight) {
    varoptions = SP.UI.$create_DialogOptions();
    options.url = FormPath;
    options.width = FormWidth;
    options.height = FormHeight;
    options.allowMaximize = false;
    options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
    SP.UI.ModalDialog.showModalDialog(options);
    }

    functionCloseCallback(result, returnValue) {
    if(result == SP.UI.DialogResult.OK)
    {
    window.location.href=window.location.href;
    }

    if(result == SP.UI.DialogResult.cancel)
    SP.UI.Notify.addNotification(‘You chose the Cancel button’);
    }

    To close the popup you can use window.frameElement.commonModalDailogClose(1,null);

    Here 1 means SP.UI.DialogResult.OK

    Thursday, January 31, 2013 2:57 AM
  • i am using for new form following script.

    NewForm.aspx its sharepoint List DisplayForm

    <a onclick="javascript:NewItem2(event, '/Lists/Leave/NewForm.aspx');javascript:return false;" href="#">Add new docuemnt</a>

    above given script i am not using i think we are very close:) but this script is not helpfull


    Regards DILDAR-SharePoint Developer

    Thursday, January 31, 2013 7:47 AM