I have a FormView InsertItemTemplate which has a databound dropdownlist. The dropdownlist displays a list of names retrieved through a SQL Server stored proc. The user has an option to add a new name to the database by clicking a button next to the dropdownlist. Clicking the button fires a javascript function, which opens a modal window. This "popup" window is where a new name and other pertinent data is entered. When the modal window closes the dropdownlist needs to refresh in order to display the new name (which was just entered in the modal window).

What is the best approach to refresh the dropdownlist? Where and when should a refresh occur (in what event)?

Thanks for your help!

Recommended Answers

All 2 Replies

found this:
In your modal

window.returnValue = "doReload";
window.close();

Then in your mainpage

var modal = window.showModal....
if (modal == "doReload") {
   window.location = window.location;
}

its in c but it can hopefully give you a starting point on where to research!

Hi,

Where did you bind the dropdownlist it have binded the dropdownlist in page load you can use this javascript

window.opener.refresh();

or

You can try like this

in child page

ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert(' Details Added Successfully!');window.close();window.opener.__doPostBack('ChildWindowPostBack', '');", true);

in parent page:

this.ClientScript.GetPostBackEventReference(this, string.Empty);

        if (this.IsPostBack)
        {
            string eventTarget = (this.Request["__EVENTTARGET"] == null) ? string.Empty : this.Request["__EVENTTARGET"];

            if (eventTarget == "ChildWindowPostBack")
            {
//bind the dropdownlist
            }
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.