Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 833
  • Last Modified:

Update Page on Template button click from gridview within Modal Popup Extender

I have a Gridview within a Panel which is associated as the PopupControlID for AJAX Modalpopup extender.
When a button outside the panel is clicked, the popup is launched successfully displaying the gridview with the datarows and template command button, however when the command button is clicked, the gridview rowcommand for the button is not being fired therefore Page updates not being done.

Code EXTRACT Example below
    <asp:Button ID="btnLaunchPopup" runat="server" Text="Display"/>
    <cc1:ModalPopupExtender ID="ModalPopupExtender1"
    runat="server"  
    TargetControlID="btnLaunchPopup"
    PopupControlID="pnlWorkArea"
     />
<asp:Panel ID="pnlWorkArea" runat="server">
<asp:GridView ID="grdWithinPanel" DataKeyNames="rowvalue" />
                    <Columns>
                        <asp:BoundField DataField ="rowvalue" HeaderText="rowheader"  />
                        <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Button ID="BtnGetCommand" runat="server" CommandName="FireMyCommand" CommandArgument="<%# Container.DataItemIndex %>" Text="Go"/>
                        </ItemTemplate>
                        </asp:TemplateField>                                                
                    </Columns>
                </asp:GridView>  
</asp:Panel>
0
angelrbrown
Asked:
angelrbrown
1 Solution
 
carlnorrbomCommented:
Hi,

I replicated your code on my devbox and apart from some minor errors:

- no runat attribute specified for the GridView
- some formatting issues for xhtml

For me it works, it does indeed fire off the row command? I suspect that if it does not fire off the command it must be related to errors in code outside of the scope you have posted here because I suspect the missing runat attribute is just a typo here?

/Carl.
0
 
angelrbrownAuthor Commented:
The runat="server" was accidentally removed in original post. I was building the code as a sample of what I have and mistakenly took it our however I found a solution to the problem by using an update panel for pnlWorkArea and within the grid added a asynchronicousPostBackTrigger on my button.

CODE EXTRACT FOR SOLUTION
    <asp:UpdatePanel ID="PnlUpdateWorkArea" runat="server">  
            <ContentTemplate>        
            <asp:Panel ID="PnlWorkArea" runat="server" style="background-color:#FFFFFF;
            border-width:1px;
            border-style:solid;
            border-color:#CCCCCC;
            padding:1px;
            width:215px;
            /*Height:100px;*/
              border-radius:5px;
              -moz-border-radius:5px;
              -khtml-border-radius:5px;
              -webkit-border-radius:5px;            
            "> 
        <asp:GridView ID="grdWithinPanel" DataKeyNames="rowvalue"
            AutoGenerateColumns="False" runat="server" CellPadding="4" ForeColor="#333333"
            GridLines="None"  ShowHeader="false" Width="100%">
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <Columns>
                <asp:BoundField DataField ="rowvaluer" HeaderText="rowheader"  />
            <asp:TemplateField>
                 <ItemTemplate>
                    <asp:UpdatePanel UpdateMode="Always" ID="UpdatePanelforpostbackwithinGrid" runat="server">
                        <ContentTemplate>                                  
                            <asp:Button ID="BtnGetCommand" runat="server" Text="Go" CommandArgument='<%# Bind("rowvaluer") %>' CommandName="FireMyCommand" EnableViewState="True" OnClientClick="HideModalPopup();" />
                        </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="BtnGetCommand" EventName="Click" />
                            </Triggers>
                    </asp:UpdatePanel>
                </ItemTemplate>
            </asp:TemplateField>                                                                      
            </Columns>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#999999" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:GridView>
            </asp:Panel>                
          </ContentTemplate>                      
    </asp:UpdatePanel>
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now