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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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)

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.