Datareader binding
It's surely simple but I can't figure out how I can deal with this basic stuff.
I have a web page with a poll. The choice items are coming from a SQL database, they can be just like Yes or No.
I bind the choices to a Radiobutton list.
On top of the choice items, I also have a Label webcontrol to write the question.
Because sadly Label don't have any Datasource property, I am struggling with this issue.
If I do this code (after opening my datareader)
If dtr.Read then
Poll_Question= dtr("Question")
End If
'-- Now bind to the radiobutton list
MyPoll.Datasource =dtr
MyPoll.Databind
Guess what's happen there ;-) I lost the first record because of the test which read the dtr first record.
Of course if I remove the test I have an error Attempt to read when no data is there.
I tried also to bind the radiobuttonlist first and only after bind the Label. No still the same error.
So for the moment the only way I found is to read twice the data !
If dtr.Read then
Poll_Question= dtr("Question")
End If
dtr.close
dtr = cmdSelect.ExecuteReader()
'-- Now bind to the radiobutton list
MyPoll.Datasource =dtr
MyPoll.Databind
dtr.close
Any idea welcome ;-)