locked
Why doesn't ajax modal popup show a datacontrol that is loaded dynamically ? RRS feed

  • Question

  • User-886220824 posted

    I am using Ajax popup extender which should show gridview upon clicking a imagebutton in inside another gridview but POPUP doesn't show any datacontrol that is populated dynamically even a label. 

    Why ? 

    <asp:UpdatePanel ID="updMdl" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <asp:HiddenField ID="lnkFake" runat="server" />
    <asp:ModalPopupExtender runat="server" BackgroundCssClass="modal" ID="mdlPopUpShowHearingsData" TargetControlID="lnkfake"
    PopupControlID="popUp">
    </asp:ModalPopupExtender>
    <asp:Panel runat="server" ID="popUp" CssClass="modalPopup">
    <asp:Label runat="server" ID="lbl" ClientIDMode="Static" CssClass="label-blue" Font-Size="Larger"></asp:Label>
    <h2>hihihiiuhhuihhuuiiuhhiu</h2>
    <asp:GridView runat="server" ID="grdviewCaseHearingsDetails" ClientIDMode="Static" AllowPaging="true"
    PageSize="15" OnPageIndexChanging="grdviewCaseHearingsDetails_PageIndexChanging"
    PagerStyle-BackColor="#99CC99" HeaderStyle-BackColor="#99CC99"
    DataKeyNames="pk_CaseHearings_ID" AutoGenerateColumns="false"
    CssClass="table table-condensed table-bordered table-striped table-responsive scrollable" Width="110%" Style="margin: -6px 9px -5px -21px"
    >
    </asp:GridView>
    </asp:Panel>
    </ContentTemplate>
    </asp:UpdatePanel>



    protected void grdViewCasesByCaseNo_RowCommand(object sender, GridViewCommandEventArgs e)
    {

    int index = Convert.ToInt32(e.CommandArgument);
    int CaseID = Convert.ToInt32(grdViewCasesByCaseNo.DataKeys[index].Value);
    
    if (e.CommandName == "cmdHearingDetails")
    {
    
    updMdl.Update();
    mdlPopUpShowHearingsData.Show();
    lbl.Text= "Show me something";
    popUp.Visible = true; } }



    Friday, February 19, 2016 7:07 AM

Answers

  • User61956409 posted

    Hi StackUnderflow,

    According to your code, we could find that you call Show() method in RowCommand event to show ModalPopupExtender. I create the following sample to reproduce your problem, the code works fine, please refer to it.

    <div>
        <asp:GridView ID="grdViewCasesByCaseNo" runat="server" OnRowCommand="grdViewCasesByCaseNo_RowCommand">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="btnshowdetails" runat="server" CommandName="cmdHearingDetails">Details</asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <br />
        <asp:UpdatePanel ID="updMdl" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:HiddenField ID="lnkFake" runat="server" />
                <asp:ModalPopupExtender runat="server" BackgroundCssClass="modal" ID="mdlPopUpShowHearingsData" TargetControlID="lnkfake"
                    PopupControlID="popUp">
                </asp:ModalPopupExtender>
                <asp:Panel runat="server" ID="popUp" CssClass="modalPopup">
                    <asp:Label runat="server" ID="lbl" ClientIDMode="Static" CssClass="label-blue" Font-Size="Larger"></asp:Label>
                    <h2>hihihiiuhhuihhuuiiuhhiu</h2>
                    <asp:GridView ID="grdviewCaseHearingsDetails" runat="server"></asp:GridView>
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("ID");
    
            dt.Rows.Add("1");
            dt.Rows.Add("2");
    
            grdViewCasesByCaseNo.DataSource = dt;
            grdViewCasesByCaseNo.DataBind();
    
            DataTable dt1 = new DataTable();
            dt1.Columns.Add("ID");
            dt1.Columns.Add("Details");
    
            dt1.Rows.Add("1", "Details1");
            dt1.Rows.Add("2", "Detail2");
    
            grdviewCaseHearingsDetails.DataSource = dt1;
            grdviewCaseHearingsDetails.DataBind();
        }
    }
    
    protected void grdViewCasesByCaseNo_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName=="cmdHearingDetails")
        {
            updMdl.Update();
            mdlPopUpShowHearingsData.Show();
            lbl.Text = "Show me something";
            popUp.Visible = true;
        }
    }
    

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 22, 2016 6:35 AM