【发布时间】:2016-05-04 16:13:49
【问题描述】:
我正在向我的 Web 应用程序添加这样的面板:
For i = 1 To amountOfRechnungspositionen + 1
Dim pnlPositon As Panel = New Panel
pnlPositon.ID = "pnlPositon" & i
pnlRechungsposition.Controls.Add(pnlPositon)
...
Next
现在如果我点击一个按钮,我想删除这个面板。 这是我的代码。
Private Sub imgDelRechnungsPosition_Click(sender As Object, e As ImageClickEventArgs) Handles imgDelRechnungsPosition.Click
amountOfRechnungspositionen = Convert.ToInt32(hfAmountofRechnungspositionen.Value)
Dim fcpnlPositon As Panel = DirectCast(pnlRechungsposition.FindControl("placeholderID$pnlPositon" + amountOfRechnungspositionen.ToString()), Panel)
fcpnlPositon.Dispose()
hfAmountofRechnungspositionen.Value = Convert.ToString(amountOfRechnungspositionen - 1)
End Sub
但是 fcpnlPositon 什么都不是。 我做错了什么?
感谢您的阅读。
【问题讨论】:
-
您是否在每次回发时都添加面板?请记住,每次回发后动态控件都会丢失
-
在回发时我这样做:如果不是 IsPostBack Then genNeueRechnungsPosition() End If EDIT: Oh sry function genNeueRechnungsPosition 是添加面板的函数
-
什么是
genNeueRechnungsPosition?可能是动态添加面板的方法?所以是的,您不会在每次回发时都添加它们吗? -
是的,我不会在每次回发时都添加它们。抱歉,我按了 Enter 并没有准备好输入
标签: asp.net vb.net dynamic panel