|
-
Apr 25th, 2003, 04:09 AM
#1
Thread Starter
New Member
Can the DataReader bind to DropDownList control ?
Hi all,
I need help on my ASP.NET Web Application.
Can the DataReader bind to DropDownList control ?
The following code give System.Data.Common.DBDataRecord error.
Dim cnn As New OleDb.OleDbConnection(strConnTeamPE)
cnn.Open()
strSQL = "SELECT sTeamID FROM TeamMaster"
Dim cmd As New OleDb.OleDbCommand(strSQL, cnn)
Dim dr As OleDb.OleDbDataReader
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
' Bind Data Reader to DropDownList
ddlTeamName.DataSource = dr
ddlTeamName.DataBind()
'Do While dr.Read
' ddlTeamName.Items.Add(dr("sTeamID"))
'Loop
If I replace last 2 lines with Do..While Loop then it's work.
So, I wonder is DataReader able for DataBind method ?
Many books does not teach binding controls with DataReader.(They used Do..While Loop or DataSet method)
But according to 4GuysFromRolla.com, it can be done. (Pls see the acticles below)
http://aspnet.4guysfromrolla.com/art...32702-1.2.aspx
Please advice.
Thanks.
Regards,
Hean
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|