I have read these forums for quite some time, but this is my first post. I apologize if the answer is to be found here, but I have come up empty-handed in my searches
The scenario:
I have an UpdatePanel that contains within it a GridView. The GridView is ItemTemplate'ed where I control all of the layout of data per row. Within each row is another UpdatePanel that contains a LinkButton. When I remove this second UpdatePanel, my FindControl() successfully finds the LinkButton I am trying to access. However, when the second UpdatePanel is present, the exact same FindControl() returns null. Below is the source:
<asp:UpdatePanel ID="UpdatePanelFacstaff" runat="server">
<ContentTemplate>
Faculty / Staff Connections<br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="false"
OnPageIndexChanging="gridView_PageIndexChanging" PageSize="1" OnRowCreated="GridView_RowCreated">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<img alt='' src='../images/profile/thumb/<%# Eval("user_guid") %>.jpg' /><a href='../profile/Default.aspx?guid=<%# Eval("user_guid") %>'><%# Eval("display_name") %></a>
- <a href='../messages/Default.aspx?to_guid=<%# Eval("user_guid") %>'>send a message</a>
<asp:Literal ID="LiteralConnected" runat="server" Text="You are connected" Visible='<%# Eval("connected") %>' />
<asp:UpdatePanel ID="UpdatePanelAddConnection" runat="server">
<ContentTemplate>
<asp:LinkButton ID="LinkButtonAddConnection" runat="server" Text="Add Connection" Visible='<%# !Boolean.Parse(Eval("connected").ToString()) %>'
CommandArgument='<%# Eval("user_guid").ToString() %>' OnCommand="AddFriend" />
<asp:Panel ID="PanelConnectionRequested" runat="server" Visible="false">
You have requested a connection with
<%# Eval("display_name") %>
.</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
And in the code-behind where "addButton" returns null:
protected void GridView_RowCreated(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Retrieve the LinkButton control from the row
//UpdatePanel rowUpdatePanel = (UpdatePanel)e.Row.FindControl("UpdatePanelAddConnection");
LinkButton addButton = (LinkButton)e.Row.FindControl("LinkButtonAddConnection");
// Set the LinkButton's CommandName property with the row's index.
addButton.CommandName = e.Row.RowIndex.ToString();
}
}
Thank you for your help with this!