Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all.

I am getting an error when i call the Link_button id which is inside GridView Item template.

then i change TargetControlI to hidden button as following:

C#
<
asp:HiddenField ID="hfHidden" runat="server" />
                           <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server" TargetControlID="hfHidden"
       PopupControlID="Panel1" BackgroundCssClass="modalBackground" OkControlID="OkButton"
       >

C#
       <asp:GridView ID="GridView1" runat="server"  AutoGenerateColumns="False" 
                            dir="ltr" CellPadding="4" ForeColor="#333333" GridLines="None" 
                            onselectedindexchanged="GridView1_SelectedIndexChanged" Width="220px" 
                            AllowSorting="True" DataSourceID="SqlDataSource1" Font-Names="B Yekan" 
                            DataKeyNames="MessageId" onrowcommand="GridView1_RowCommand" 
                            onrowdatabound="GridView1_RowDataBound">
                            <AlternatingRowStyle BackColor="White" />
                                    <Columns>
<asp:TemplateField HeaderText="show"><EditItemTemplate>
                                                            
</EditItemTemplate>
<ItemStyle Width="40%" CssClass="Col1" HorizontalAlign="Center" 
        VerticalAlign="Middle"></ItemStyle>
<ItemTemplate>

                                <asp:LinkButton ID="LinkButton_Subject" runat="server" CommandArgument="<%# Container.DataItemIndex %>"
                                    OnClick="LinkButton_Subject_Click" Text="show" CommandName="ViewComments"></asp:LinkButton>
                                <asp:Label ID="Label_MessageID" runat="server" Text='<%# Eval("MessageID") %>' Visible="False"></asp:Label>

                          
</ItemTemplate>
</asp:TemplateField>


and in code behind :

C#
  protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)  
            {
                case "ViewComments":
                    ModalPopupExtender.Show();
                    break;
            } 
        }

and 

protected void LinkButton_Subject_Click(object sender, EventArgs e)
        {
            
            ModalPopupExtender.Show();
         
  
        
        }

but when click on link button , don't show popup panel

thanks a lot.
Posted
Updated 4-Jun-15 6:40am
v2
Comments
Mohamed El khames Bakir 4-Jun-15 12:54pm    
why did you use the onclick event on the show buttom doesn't the onrowcommand event do the job ?
bernova 4-Jun-15 13:53pm    
two solution don't work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900