cancel ItemDataCreated or ItemDataBound (stop row being created)
I am binding a data row toa few grids.
When binding to one datagrid, I do not want items that have a field "username" equal to "WOOF".
Is there a way in itemcreated or itembound to stop the row being created?
Woka
Re: cancel ItemDataCreated or ItemDataBound (stop row being created)
I have done:
VB Code:
Private Sub grdUDFs_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdUDFs.ItemDataBound
Dim Item As DataGridItem = e.Item
If Item.ItemType = ListItemType.AlternatingItem Or Item.ItemType = ListItemType.Item Then
Dim UDFItem As UDF = CType(Item.DataItem, UDF)
If UDFItem.Web Then
'Populate grid item
Else
Item.Visible=False
End if
End If
End Sub
Is this OK?
Woof
Re: cancel ItemDataCreated or ItemDataBound (stop row being created)
You can do that, or you can use a DataRowView object which has just what you want to display, you can use that for that particular datagrid.