Hi Micah,
I have created sample. Please refer the below code. Here panel contains the name.
HTML
<div>
<asp:DataList ID="GetAll" runat="server">
<ItemTemplate>
<table>
<tr>
<td>
<asp:Label ID="Label1" Text='<%#DataBinder.Eval(Container.DataItem,"Id") %>' runat="server" />
</td>
<td>
<asp:Panel ID="Panel1" runat="server" Visible="false">
<asp:Label ID="Label2" Text='<%#DataBinder.Eval(Container.DataItem,"Name") %>' runat="server" />
</asp:Panel>
</td>
<td>
<asp:LinkButton ID="btnDisplayPanel" runat="server" OnClick="ShowPanel">Display Name</asp:LinkButton>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div>
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Id", typeof(int)), new DataColumn("Name") });
dt.Rows.Add(1, "John Hammond");
dt.Rows.Add(2, "Mudassar Khan");
dt.Rows.Add(3, "Suzanne Mathews");
dt.Rows.Add(4, "Robert Schidner");
GetAll.DataSource = dt;
GetAll.DataBind();
}
}
protected void ShowPanel(object sender, EventArgs e)
{
DataListItem item = (DataListItem)(sender as LinkButton).NamingContainer;
Panel pnl = item.FindControl("Panel1") as Panel;
if (((LinkButton)(sender)).Text.Trim() == "Display Name")
{
((System.Web.UI.WebControls.LinkButton)(sender)).Text = "Hide Name";
}
else
{
((System.Web.UI.WebControls.LinkButton)(sender)).Text = "Display Name";
}
if (pnl.Visible == false)
{
pnl.Visible = true;
}
else
{
pnl.Visible = false;
}
}
Screenshot