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
 
Back
Top