PC Review


Reply
Thread Tools Rate Thread

DataTextField DropDownlist

 
 
Rafael Metring
Guest
Posts: n/a
 
      2nd Mar 2004
How set DAtaTextField and DataValueField in dropdOwnlist

I use this to populate..

Dim sqlConn As SqlCeConnection = Nothing

Dim dr As SqlCeDataReader

Dim da As SqlCeDataAdapter

Dim ds As DataSet = New DataSet

Dim strsql As String

Try

sqlConn = New SqlCeConnection("Data Source =\My Documents\multiseguros.sdf")

Dim insertCommand As SqlCeCommand = sqlConn.CreateCommand()

strsql = "select * from Produto"

sqlConn.Open()

da = New SqlCeDataAdapter(strsql, sqlConn)

da.Fill(ds)

lstProduto.DataSource = ds.Tables(0).DefaultView

lstProduto.Refresh()

Catch err As SqlCeException

MessageBox.Show(err.Message)

Finally

If sqlConn.State = ConnectionState.Open Then

sqlConn.Close()

End If

End Try


 
Reply With Quote
 
 
 
 
William Ryan eMVP
Guest
Posts: n/a
 
      2nd Mar 2004
Rafael:
"Rafael Metring" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How set DAtaTextField and DataValueField in dropdOwnlist
>
> I use this to populate..
>
> Dim sqlConn As SqlCeConnection = Nothing
>
> Dim dr As SqlCeDataReader
>
> Dim da As SqlCeDataAdapter
>
> Dim ds As DataSet = New DataSet
>
> Dim strsql As String
>
> Try
>
> sqlConn = New SqlCeConnection("Data Source =\My

Documents\multiseguros.sdf")
>
> Dim insertCommand As SqlCeCommand = sqlConn.CreateCommand()
>
> strsql = "select * from Produto"
>
> sqlConn.Open()
>
> da = New SqlCeDataAdapter(strsql, sqlConn)
>
> da.Fill(ds)
>
> lstProduto.DataSource = ds.Tables(0).DefaultView
>
> lstProduto.Refresh()
>
> Catch err As SqlCeException
>
> MessageBox.Show(err.Message)
>
> Finally
>
> If sqlConn.State = ConnectionState.Open Then
>
> sqlConn.Close()
>
> End If
>
> End Try
>
>


The .DisplayMember and .ValueMember fields are probably what you are looking
for


 
Reply With Quote
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      2nd Mar 2004
Use the DisplayMember and ValueMember properties of the ComboBox to define
which fields are to be displayed and used as the value member when
retrieving the user's selection:-
lstProduto.DisplayMember = "DisplayFieldName"
lstProduto.ValueMember = "ValueFieldName"

Where you substitute the fieldnames from your datasource.

Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

"Rafael Metring" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How set DAtaTextField and DataValueField in dropdOwnlist
>
> I use this to populate..
>
> Dim sqlConn As SqlCeConnection = Nothing
>
> Dim dr As SqlCeDataReader
>
> Dim da As SqlCeDataAdapter
>
> Dim ds As DataSet = New DataSet
>
> Dim strsql As String
>
> Try
>
> sqlConn = New SqlCeConnection("Data Source =\My
> Documents\multiseguros.sdf")
>
> Dim insertCommand As SqlCeCommand = sqlConn.CreateCommand()
>
> strsql = "select * from Produto"
>
> sqlConn.Open()
>
> da = New SqlCeDataAdapter(strsql, sqlConn)
>
> da.Fill(ds)
>
> lstProduto.DataSource = ds.Tables(0).DefaultView
>
> lstProduto.Refresh()
>
> Catch err As SqlCeException
>
> MessageBox.Show(err.Message)
>
> Finally
>
> If sqlConn.State = ConnectionState.Open Then
>
> sqlConn.Close()
>
> End If
>
> End Try
>
>



 
Reply With Quote
 
Rafael Metring
Guest
Posts: n/a
 
      3rd Mar 2004
Tanks willian and Petter

Rafael

"Peter Foot [MVP]" <(E-Mail Removed)> escreveu na mensagem
news:(E-Mail Removed)...
> Use the DisplayMember and ValueMember properties of the ComboBox to define
> which fields are to be displayed and used as the value member when
> retrieving the user's selection:-
> lstProduto.DisplayMember = "DisplayFieldName"
> lstProduto.ValueMember = "ValueFieldName"
>
> Where you substitute the fieldnames from your datasource.
>
> Peter
>
> --
> Peter Foot
> Windows Embedded MVP
> OpenNETCF.org Senior Advisor
> www.inthehand.com | www.opennetcf.org
>
> "Rafael Metring" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > How set DAtaTextField and DataValueField in dropdOwnlist
> >
> > I use this to populate..
> >
> > Dim sqlConn As SqlCeConnection = Nothing
> >
> > Dim dr As SqlCeDataReader
> >
> > Dim da As SqlCeDataAdapter
> >
> > Dim ds As DataSet = New DataSet
> >
> > Dim strsql As String
> >
> > Try
> >
> > sqlConn = New SqlCeConnection("Data Source =\My
> > Documents\multiseguros.sdf")
> >
> > Dim insertCommand As SqlCeCommand = sqlConn.CreateCommand()
> >
> > strsql = "select * from Produto"
> >
> > sqlConn.Open()
> >
> > da = New SqlCeDataAdapter(strsql, sqlConn)
> >
> > da.Fill(ds)
> >
> > lstProduto.DataSource = ds.Tables(0).DefaultView
> >
> > lstProduto.Refresh()
> >
> > Catch err As SqlCeException
> >
> > MessageBox.Show(err.Message)
> >
> > Finally
> >
> > If sqlConn.State = ConnectionState.Open Then
> >
> > sqlConn.Close()
> >
> > End If
> >
> > End Try
> >
> >

>
>



 
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
Getting DropDownList DataTextField Value? Given the SelectedValue and/or SelectedIndex jobs Microsoft ASP .NET 0 6th Nov 2006 09:17 PM
DropDownList DataTextField and ToString() Andrew Robinson Microsoft C# .NET 2 2nd May 2006 08:55 PM
Dropdownlist,DataTextField,DataValueField ? Sam Microsoft ASP .NET 1 18th Feb 2005 11:52 AM
dropdownlist: 2 columns in the DataTextField nicholas Microsoft ASP .NET 5 3rd Dec 2004 06:25 PM
Re: DataTextField in DropDownList Scott M. Microsoft VB .NET 0 25th Feb 2004 10:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:21 PM.