更新面板不会动态创建动态创建的按钮单击事件控件 [英] Update Panel not updating dynamically created controls on dynamically created button click event

查看:72
本文介绍了更新面板不会动态创建动态创建的按钮单击事件控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

动态创建的控制按钮点击事件工作并刷新第一个按钮上的数据,但是在第一个按钮点击更新面板上的动态面板中的多个按钮点击事件后,在删除时不刷新动态创建的面板。

 <   asp:UpdatePanel     ID   =  updateitem    runat   =  server    UpdateMode   = 条件 >  



内部面板我正在创建动态控制和内部动态控制再次动态控制。当我试图通过以下方法删除面板内创建的控件时,我想删除按钮上的每个子面板。



为了更好地理解,请按照下面的示例:

 <   asp:Panel     Id   =  Panel1    runat   =  服务器 > 这是设计页面中的实际面板

< asp:Panel Id = PanelD1 runat = 服务器 > 这是动态创建的面板,代码在

< asp:Panel Id = PanelD1Child1 runat = 服务器 >

这是PanelD1的动态子面板,代码在

后面< / asp:面板 >

< asp:Panel Id = PanelD1Child2 runat = 服务器 >

这是PanelD1的动态子面板,代码在

< / asp:Panel >

< / asp:Panel >

< / asp:Panel >





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





它适用于动态创建的面板内的第一个按钮点击但当我点击同一面板内的另一个按钮时,它遵循上面的方法并删除控件,但UpdatePanel没有刷新面板,这就是为什么页面在删除按钮单击后显示相同的控件。

解决方案

我自己已经解决了。谢谢所有人对于您的宝贵意见。



注意:在动态面板创建或动态控制创建期间,尝试为每个控件生成唯一ID,即使在删除控件/面板之后也是如此。 / BLOCKQUOTE>

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.

<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:

<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>



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.

解决方案

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.


这篇关于更新面板不会动态创建动态创建的按钮单击事件控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆