我看了,但我想让它在页面的page_load()中执行。如下代码怎么改才行?谢谢了!
Private Sub DataGrid1_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
Dim hk As LinkButton
hk = e.Item.FindControl("kk")
hk.Visible = False
End Sub
目的就是让linkbutton控件在页面第一次运行时隐藏或显示。
我试了一下,还是不得~它提示“未将对象引用设置到对象的实例。”
行 78: Dim lk As LinkButton
行 79: lk = e.Item.FindControl("kk")
行 80: lk.Visible = True
行 81: End Sub
代码如下:
datagrid控件的ID是"DG",它里面的linkbutton控件的ID是"kk"。
Private Sub DG_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DG.ItemDataBound
Dim lk As LinkButton
lk = e.Item.FindControl("kk")
lk.Visible = false
End Sub