0
votes

i have a modal popup extender, link button (tempalte field), fake button in grid view. the target control id for mpe is fake button, popup control is a panel having another grid to dispaly details of the main request. i am calling mpe show method in link button click event but its not showing up. please help as i coudld not find solution though researched. plese find my mark up an code.

Select operation in this grid

<asp:GridView ID="grdDULead" runat="server" AllowPaging="True" AllowSorting="True"
 Caption="AMT Team Approval Details" CellPadding="3" CssClass="Grid"
 Height="75px" Style="left: 122px;
 position: absolute; top: 342px" Width="792px" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="Transition Request Number" OnRowCommand="grdDULead_RowCommand">
 <FooterStyle BackColor="White" CssClass="GridFooter" />
 <Columns>
 <asp:TemplateField>
    <ItemTemplate>
    <asp:LinkButton ID="grDULeadlnkSelect" runat="server" ForeColor="Red" OnClick="grDULeadlnkSelect_Click" CausesValidation="False" CommandName="SelectRow">select</asp:LinkButton>&nbsp;

     <asp:Button ID="btnfake" runat="server" CausesValidation="False" ForeColor="Red" Text="Fake" Visible="False" />
                <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnfake" PopupControlID="pnlCDAMTClar" BackgroundCssClass="modalBackground">
                  </cc1:ModalPopupExtender>
       </ItemTemplate>
    </asp:TemplateField>

Popup control markup





Code-behind link button click (tempalte filed) protected void grDULeadlnkSelect_Click(object sender, EventArgs e) {

        GridViewRow clickedRow = ((LinkButton)sender).NamingContainer as GridViewRow;
        lblReqno.Text=clickedRow.Cells[1].Text.ToString();
        ModalPopupExtender mpeTemp = ((ModalPopupExtender)(clickedRow.FindControl "ModalPopupExtender1")));
          mpeTemp.Show();
    }
1
debug your code and see what you get in mpeTemp. First confirm that it is not null.And one more thing why you are using modelpopextender for each row of gridview? - Neha
techbrij.com/772/show-modal-popup-edit-aspdotnet-gridview best way to do. I had implemented and it works fine. - Neha
if (e.Row.RowType == DataControlRowType.DataRow) { AjaxControlToolkit.ModalPopupExtender pce = e.Row.FindControl("PopupControlExtender1") as AjaxControlToolkit.ModalPopupExtender; - Neha
put your button only in template field give the command argument as id and command name to button eg: my button : <asp:Button ID="ButtonAddActivity" Text="Add Activity" class="btnNext" CommandName="AddActivity" CommandArgument='<%# Eval("SNO") + ";" + Eval("OneFee") %>' runat="server"></asp:Button> - Neha
and on row command protected void GridViewActivityGroup_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "AddActivity") { HyperLinkActivity.Visible=true;ModalPopupExtenderActivity.Show(); }} - Neha

1 Answers

0
votes

I will suggest not to continue with above code as you used, Because instance of ModelPop Extender created for each row which will decreases performance.

You can use a alternative solution as:

1.Keep Facke button inside gridview as you already did.

2.Remove ModelPopup Extender from Gridview and keep it outside of Gridview. Also add a fake linkbutton as below:

<asp:LinkButton ID="LnkFake" runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"     TargetControlID="LnkFake" PopupControlID="pnlCDAMTClar" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>

3.At server side, on click of your button show ModelPop as below:

ModalPopupExtender1.Show()

Hope this will help you, Let me know if you have any concern.