Dipa Ahuja

Dipa Ahuja

  • NA
  • 3.1k
  • 715.4k

display panel in gridview

Mar 16 2010 9:34 AM
hi.. i wnt to display panel inside gridview.

i have taken button field and commandname of it button is "EDIT" and when it is clicked that panel should be display..


this way..
<ItemTemplate>
<asp:Panel ID="pe" visible="false" runat="server">
               <table class="basic" runat="server" id="tbledit" width="400" border="0">
                    <tr><td>Title:</td>
                    <td><asp:TextBox ID="txtaname" runat="server" /></td>
                    </tr>
                    <tr><td>Description:</td>
                    <td><asp:TextBox ID="TextBox2" runat="server" /></td>
                    </tr><tr><td colspan="2" align="center">
                        <asp:Button ID="btncreate" CssClass="btn" runat="server" Text="Create" OnClick="btncreate_Click" />&nbsp;&nbsp;&nbsp;
                        <asp:Button ID="btncancel" CssClass="btn" runat="server" Text="Cancel" OnClick="btncancel_Click" />
                    </td>
                    </tr>
                 </table>
               </asp:Panel>
</ItemTemplate>

             <asp:ButtonField ItemStyle-VerticalAlign="top" ButtonType="Button" CommandName="Edit"/>


.CS

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {   
        int index=Convert.ToInt32(e.CommandArgument);

        Panel pn = (Panel)GridView1.Rows[index].FindControl("pe");
        if (e.CommandName == "Edit")
        {
            pn.Visible = true;
 
        }
       
    }



but its not working.... i means when i click on buttonfield it doesnt displaying the panel

Answers (2)