item in dataset

  • Thread starter Thread starter Per W.
  • Start date Start date
P

Per W.

Hi, how can i check one spesific item in a dataset and then hide that item
if there isnt any data in it? in a gridview i can use e.row.cells(1).text to
read the value, but how can i read one item in a dataset?

/Per W.
 
What is the item? Does the dataset have many tables or just one? Can you
provide more specifics?
 
Jeff Allan said:
What is the item? Does the dataset have many tables or just one? Can you
provide more specifics?

Sorry, its datalist, not dataset and one table. if i use the gridview then i
can use the rowdatabound and e.row.cells(number).text to read the context of
the cell. But i want to use datalist and read the context of a item in that
datalist.

/Per W.
 
There are a few ways to read data. Did you want to read it at Data Bind
time? If so, you can use the ItemDataBound event to evaluate the data.
Then from there you can hide or show the list item. Or you can loop through
the list and decide.

To Loop:
Dim myItem as DataListItem
For Each myItem in Datalist1.Items
'Add code here to validate and take action.
Loop

DataBind: (From MSDN Library Help)
Private Sub DataList1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) _
Handles DataList1.ItemDataBound
Dim dob As DateTime
Dim doblabel As Label
doblabel = CType(e.Item.FindControl("Label1"), Label)
dob = CType(doblabel.Text, DateTime)
If dob.Month = Today.Month Then
e.Item.BackColor = Color.Yellow
End If
End Sub
 
Jeff Allan said:
There are a few ways to read data. Did you want to read it at Data Bind
time? If so, you can use the ItemDataBound event to evaluate the data.
Then from there you can hide or show the list item. Or you can loop
through the list and decide.

To Loop:
Dim myItem as DataListItem
For Each myItem in Datalist1.Items
'Add code here to validate and take action.
Loop

DataBind: (From MSDN Library Help)
Private Sub DataList1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) _
Handles DataList1.ItemDataBound
Dim dob As DateTime
Dim doblabel As Label
doblabel = CType(e.Item.FindControl("Label1"), Label)
dob = CType(doblabel.Text, DateTime)
If dob.Month = Today.Month Then
e.Item.BackColor = Color.Yellow
End If
End Sub

Thanx

/Per W.
 
Back
Top