Getting a GridView to refresh after a modal popup extender?

I have a GridView on a page with an AJAX ModalPopupExtender on each row of the GridView.
If a link on any of the rows is clicked them the ModalPopupExtender is shown. The ModalPopupExtender has a form and if you click 'save' then the data is modified and that spefic row is no longer to be shown in the GridView.

The problem is that when I click 'Save' the ModalPopupExtender will disappear but I don't know how or where to do the GridView.DataBind.

Any ideas?

Who is Participating?
Here is a sample
<asp:Button ID="MyButton" Text="Click Here" runat="server" />

<asp:Panel ID="MyPanel" runat="server">
  <asp:DropDownList ID="MyDropDown" runat="server">
    <asp:ListItem Value="1" Text="Option 1" />
   <asp:ListItem Value="2" Text="Option 2" />
   <asp:ListItem Value="3" Text="Option 3" />
  <asp:Button ID="SaveBtn" Text="Save" OnClick="SaveBtn_Click" runat="server" />
  <asp:Button ID="CancelBtn" Text="Cancel" runat="server" />

<ajaxtool:ModalPopupExtender ID="Mpe1" TargetControlID="MyButton"
        CancelControlID="CancelBtn" PopupControlID="MyPanel" runat="server" />

Then add your code behind to the SaveBtn Button

public void SaveBtn_Click(object sender, EventArgs e)
  string selectedOption = MyDropDown.SelectedValue;

Open in new window

Use the Click event of the save button. The button will run the server code and then hide the modalpopup. Remember the button on the ModalPopup is on the same page and the server code is run like any other button.

 protected void BtnSave_Click(object sender, EventArgs args)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.