i have taken button field and commandname of it button is "EDIT" and when it is clicked that panel should be display..
this way..
| Title: | |
| Description: | |
.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

VasanthPosted Mar 16, 2010, 2:51 PM
<Columns>
<asp:TemplateField>
<EditItemTemplate>
<asp:Panel ID="pe" runat="server" >
<table 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" />
<asp:Button ID="btncancel" CssClass="btn" runat="server" Text="Cancel" OnClick="btncancel_Click" />
td>
tr>
table>
asp:Panel>
EditItemTemplate>
asp:TemplateField>
<asp:ButtonField ItemStyle-VerticalAlign="top" ButtonType="Button" CommandName="Edit" Text="Edit" />
Columns>
asp:gridview>
And also , remove panel visibility in code behind.
//int index = Convert.ToInt32(e.CommandArgument);
//Panel pn = (Panel)Gridview1.Rows[index].FindControl("pe");
//if (e.CommandName == "Edit")
//{
// pn.Visible = true;
//}
Thanks,
Vasanth.
Dipa AhujaPosted Mar 17, 2010, 10:19 AM