G
Guest
i have a drop down list fill using the following code:
If IsPostBack Then
'Put user code to initialize the page here
' create a sqlconnection
Dim cnn As SqlConnection = New SqlConnection("Data
Source=localhost;Initial catalog=Northwind;" & _
"Integrated Security=SSPI")
'create a sql command
Dim cmd As SqlCommand = cnn.CreateCommand
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = "SELECT * FROM Suppliers"
' Set up the DataAdapter and fill the dataset
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = cmd
Dim ds As Suppliers = New Suppliers
da.Fill(ds, "Suppliers")
Dim suppROW As Suppliers.SuppliersRow
For Each suppROW In ds.Suppliers
Me.ddlData.Items.Add(suppROW.SupplierID & suppROW.CompanyName)
Next
i want to set the text of the drop down to companyname
and the value to the supplierID. What am i missing?
thanks
kes
If IsPostBack Then
'Put user code to initialize the page here
' create a sqlconnection
Dim cnn As SqlConnection = New SqlConnection("Data
Source=localhost;Initial catalog=Northwind;" & _
"Integrated Security=SSPI")
'create a sql command
Dim cmd As SqlCommand = cnn.CreateCommand
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = "SELECT * FROM Suppliers"
' Set up the DataAdapter and fill the dataset
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = cmd
Dim ds As Suppliers = New Suppliers
da.Fill(ds, "Suppliers")
Dim suppROW As Suppliers.SuppliersRow
For Each suppROW In ds.Suppliers
Me.ddlData.Items.Add(suppROW.SupplierID & suppROW.CompanyName)
Next
i want to set the text of the drop down to companyname
and the value to the supplierID. What am i missing?
thanks
kes