
Protected Sub dgLimit_ItemDataBound()Sub dgLimit_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgLimit.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
dosomething()
End If
If e.Item.ItemType = ListItemType.EditItem Then '判断是否为编辑状态
Dim cbl As CheckBoxList = CType(e.Item.FindControl("cblEdit"), CheckBoxList) '例如EditItemTemplate有一cblEdit的控件
If (cbl IsNot Nothing) Then '如果控件不为空
dosomethingwith(CType(e.Item.FindControl("cblEdit"), CheckBoxList)) '操作该控件
End If
End If
End Sub
本文介绍如何在 ASP.NET 应用中处理 DataGrid 的 ItemDataBound 事件,通过不同条件判断对列表项和编辑项进行操作。针对列表项进行通用处理,并针对编辑状态下的特定控件 CheckBoxList 进行个性化设置。
210

被折叠的 条评论
为什么被折叠?



