PC Review


Reply
Thread Tools Rate Thread

Binding to DataSet

 
 
sck10
Guest
Posts: n/a
 
      3rd Nov 2004
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()


 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      4th Nov 2004
How about setting the DataTextField property of the DropDown with the field
name that you wish to show?


"sck10" <(E-Mail Removed)> wrote in message
news:uXE%(E-Mail Removed)...
> 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()
>
>



 
Reply With Quote
 
Karl Seguin
Guest
Posts: n/a
 
      4th Nov 2004
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-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How about setting the DataTextField property of the DropDown with the

field
> name that you wish to show?
>
>
> "sck10" <(E-Mail Removed)> wrote in message
> news:uXE%(E-Mail Removed)...
> > 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()
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding to a DataSet with more than one DataTable =?Utf-8?B?RGljaw==?= Microsoft ASP .NET 9 7th Feb 2007 08:07 AM
help binding a dataset Jake Smythe Microsoft VB .NET 2 17th Nov 2005 08:03 AM
DataSet Binding Ghost Microsoft Dot NET Compact Framework 6 5th Aug 2004 07:06 AM
Re: Dataset Binding Brian Parlier Microsoft ADO .NET 1 16th Mar 2004 08:21 PM
BUG in Dataset Binding?? Juergen Bronn Microsoft Dot NET Framework Forms 0 17th Jul 2003 11:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:52 AM.