Problem reading DataReader after Databind
I have a group of data items that I'm displaying using a repeater. Two of the data items are the same (date and employee) for all records. I want to pull these out of the report and just show them once in my table. I've tried using the <%# DataBinder.Eval(Container.DataItem, "date")%> in the Repeater header, but it does not show up.
I've taken these fields out of the repeater and set up two labels (consultdate and consultemp). Now I've tried to assign the values to these using the following code:
SqlConnection1.Open()
GetConsultHist.Parameters.Item("@pid").Value = ptid.Text
Dim myHistReader As SqlDataReader = GetConsultHist.ExecuteReader
If myHistReader.Read Then
consultdate.Text = myHistReader.Item(1)
consultemp.Text = myHistReader.Item(0)
Else
consultdate.Text = "data not available"
End If
ConsultRepeater.DataSource = myHistReader
ConsultRepeater.DataBind()
SqlConnection1.Close()
The problem with this solution is that the data in the repeater is missing the first record. I solved that by setting the datasource and databinding above the myHistReader.read, but doing that always returns "data not available" although there are clearly records on the page.
So, I'm thinking that I need to reset the reader before I do a .read, but I don't know how to do this.
Any hints would be greatly appreciated!
|