Binding to DataSet

  • Thread starter Thread starter sck10
  • Start date Start date
S

sck10

Hello,

I have the following code that I am try to use to populate a DropDownBox
(ddlTerminationType1). The List that I am getting is as follows:
"System.Data.DataRowView".

Any help with this would be appreciated, sck10


Dim dsTermType As DataSet = New DataSet()
Dim prmTermType As OleDbParameter
Dim cmdTermType As New OleDb.OleDbCommand("sp_web_Search", cnnSearch)
cmdTermType.CommandType = CommandType.StoredProcedure
'Declare Parameters
prmTermType = cmdTermType.Parameters.Add("@strParm01", OleDbType.VarChar)
: prmTermType.Value = "FindTerminationType"
prmTermType = cmdTermType.Parameters.Add("@strParm02", OleDbType.VarChar)
: prmTermType.Value = "NoParameter"
prmTermType = cmdTermType.Parameters.Add("@strParm03", OleDbType.VarChar)
: prmTermType.Value = "NoParameter"
prmTermType = cmdTermType.Parameters.Add("@strParm04", OleDbType.VarChar)
: prmTermType.Value = "NoParameter"
Dim spTermType As New OleDb.OleDbDataAdapter(cmdTermType)
spTermType.Fill(dsTermType, "MyDataSet")
ddlTerminationType1.DataSource = dsTermType
ddlTerminationType1.DataBind()
 
How about setting the DataTextField property of the DropDown with the field
name that you wish to show?
 
And the DataValueField with the value field you want ..

And to expand on Scott's answer:

ddlTerminationType1.DataSource = dsTermType
ddlTerminationType1.DataTextField = "Name"
ddlTerminationType1.DataValueField = "Id"
ddlTerminationType1.DataBind()

assuming sp_web_Search returns a result set with a column named "Name" and
"Id"

Karl
 

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

Back
Top