473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Binding to DataSet

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()
Nov 18 '05 #1
2 1117
How about setting the DataTextField property of the DropDown with the field
name that you wish to show?
"sck10" <sc***@online.nospam> wrote in message
news:uX****************@TK2MSFTNGP14.phx.gbl...
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()

Nov 18 '05 #2
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

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Scott M." <s-***@nospam.nospam> wrote in message
news:u3**************@tk2msftngp13.phx.gbl...
How about setting the DataTextField property of the DropDown with the field name that you wish to show?
"sck10" <sc***@online.nospam> wrote in message
news:uX****************@TK2MSFTNGP14.phx.gbl...
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()


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
6
by: Omar | last post by:
When I try to databind my comboBox (specifically field "emplcode") to a filled dataset , the contents of the comboBox displays a bunch of "System.Data.DataRowView". I assume the amount of times...
13
by: Paul Slavin | last post by:
I have a textbox bound to a dataview, when I update the text in the textbox no changes take place in the underlying dataset. Why is this?? any answers appreciated, as to due to the underlying...
4
by: bardo | last post by:
Does anyone knwo how I can bind a textbox to a single dataset/dataTable row? The following will give me only a Column: textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text",...
5
by: Jason Huang | last post by:
Hi, Is it possible to bind DataReader to a DataGrid in C# windows form? And how? And can we update data in a DataSet by using the DataReader? Thanks for help. Jason
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.