Conditionally display DataGrid or DalaList content

D

Danny Ni

Hi,

Is there a way to selectively display content of a DataGrid or DataList?
Normally I bind them to datareader or datatable, and they will display all
the rows, what if I don't want to display some of the rows.
Please don't tell me get rid of the rows from datareader or datatable,
that's not the answer I am looking for.

TIA
 
J

Joe Fallon

Here is an untested idea:

Air code:

Private Sub dg_ItemDataBound(ByVal sender As System.Object, ByVal e As
DataGridItemEventArgs) Handles dg.ItemDataBound
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim oHyl1 As HyperLink = CType(e.Item.FindControl("hyl1"), HyperLink)
oHyl1.Visible=False
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top