Click here to Skip to main content
15,065,636 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
On dynamically created control button click event working and refreshing data on 1st button click but on multiple button click event in Panel inside dynamic panel after 1st button click update panel not refreshing dynamically created panel on delete.
HTML
<asp:UpdatePanel ID="updateitem" runat="server" UpdateMode="Conditional">

Inside panel i am creating dynamic control and inside dynamic control again dynamic control.When i am trying to delete created control inside panel through below method and i want to delete each Child panel on button click.

for better understanding follow the below example:
HTML
<asp:Panel Id="Panel1" runat="Server"> this is actual panel in design page

<asp:Panel Id="PanelD1" runat="Server"> this is dynamic created panel in code behind

<asp:Panel Id="PanelD1Child1" runat="Server"> 

this is dynamic child panel of PanelD1 in code behind 

</asp:Panel>

<asp:Panel Id="PanelD1Child2" runat="Server"> 

this is dynamic child panel of PanelD1 in code behind

</asp:Panel>

</asp:Panel>

</asp:Panel>


C#
if (DynamicPanel.Controls.Contains(CustPanel))
{
  DynamicPanel.Controls.Remove(CustPanel);
  CustPanel.Dispose();
  updateitem.Update();
}


It works for 1st button click inside dynamically created panel but when i click another button inside same panel it follow the above method and removes control but UpdatePanel is not refreshing Panel that's why page is showing the same controls after delete button click.
Posted
v13
Comments
F-ES Sitecore 11-Dec-15 3:36am
   
I don't fully understand the issue, but most problems with dynamic controls come about because you aren't re-creating the dynamic controls on each page postback. The asp.net framework won't persist controls you create yourself, they are not recreated when the page does a postback, you need to re-create them yourself, and also re-attach any events etc.
itsathere 11-Dec-15 3:58am
   
on postback event in Page_Load i have recreated that panel again and if i try to delete from same panel then it's not working but if i delete from another panel it's working fine.
Sudheer Kumar Tiwari 14-Dec-15 23:33pm
   
Use
itsathere 18-Dec-15 0:10am
   
Use?.If you have idea then reply.Why should you reply if u r unable to explain.

1 solution

I have solved it myself.Thanks to all for your valuable comments.

Note: During dynamic panel creation or dynamic control creation try to generate unique id for each and every control even after deletion of controls/Panel.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900