I have usercontrol (called A) and update panel in it
Following are the control in my updatepanel
1. gridview with link button
2. DIV outside the gridview to load the usercontrol (B) from c#
when i hit the link button of gridview i am loading my usercontrol(B) dynamically from code behind and adding it to the DIV which is working fine. I have button inside the the usercontrol (B) and if i hit the button it doesn't trigger the action.
Not sure why it doesn't trigger the click event. i googled and tried enabling ChildrenAsTriggers="true" though it didn't work. any suggestion please
Here is the skeleton,
Test.ascx :
<asp:UpdatePanel ID="upList" runat="server" ChildrenAsTriggers="true" >
<ContentTemplate>
<asp:GridView ID="gvList" AutoGenerateColumns="false" runat="server" Visible="true" Width="95%"
OnRowDataBound="gvList" DataKeyNames="Id" GridLines="None"
ShowFooter="false">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:label id="lbltext" runat="server" text = "TestLinkbutton"/>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="Template" OnClick="Template_Click" Text = "TestPostback" runat="server" Width="150px"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<div style="width: 500px;" id="divContainer" runat="server">
<br style="clear: left;" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
on Template_Click event i am loading the user control from code behind and adding it to the div[divContainer]
i tried to investigate in deeper and found that the update panel causing the issue. If i use the below code[rfered one of your article] on the page load event then it works fine. the button triggers it's action. but when i click the button which is in gridview, it should not post back as it is in update panel, but it postback.
private void RegisterPostBackControl()
{
foreach (GridViewRow row in gvList.Rows)
{
LinkButton lnkFull = row.FindControl("Template") as LinkButton;
ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(lnkFull);
}
}
protected void Template_Click(object sender, EventArgs e)
{
LinkButton lb = (LinkButton)sender;
GridViewRow row = (GridViewRow)lb.NamingContainer;
if (row != null)
{
// loading user control here
}
}
any help please