views:

2787

answers:

1

Hey everyone,

I'm having a heck of a time trying to get a gridview to refresh its data after a modalpopup adds a new record to the database. Ive tried the following with no luck.

 <cc2:ModalPopupExtender ID="mdlPopup" runat="server" OnOkScript="__doPostBack('<%= gvRecommendations.ClientID %>', '');" BackgroundCssClass="modalBackground"
            TargetControlID="lbtnRecommendationsAddNew" PopupControlID="pnlAddNewRecommendation">
        </cc2:ModalPopupExtender>
        <asp:Panel ID="pnlAddNewRecommendation" runat="server" CssClass="confirm-dialog" style="display:none;" Width="500px">
            <div class="inner">
                <h2>New Suppressed Recomendation</h2>
                <div class="base">
                    <table width="100%" cellpadding="5" cellspacing="0">
                        <tr>
                            <td align=left>
                                <asp:DropDownList ID="ddlRecomendations" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td align="left">
                                <asp:Button ID="btnAddRecommendation" OnClick="btnAddRecommendation_Click" runat="server" Text="Submit" />
                                &nbsp;|&nbsp;
                                <asp:LinkButton ID="btnCancel" runat="server" Text="Cancel" ForeColor="Blue" />
                                <asp:LinkButton id="lbtnTopLeft" runat="server" CssClass="close" />
                                </div>

                            </td>
                        </tr>
                    </table>   
                </div>
            </div>
        </asp:Panel>

Ive also tried adding this with no luck after adding the record to the DB:

this.gvSupressedRecommendations.DataBind();
this.UpdatePanel1.Update();

I know im close but can't seem to get this to refresh.

+2  A: 

Try reassigning your datasource before you rebind. This should work. I.e.

gvSupressedRecommendations.DataSource = <...>;
gvSupressedRecommendations.DataBind();
cdonner