473,408 Members | 2,477 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,408 software developers and data experts.

fill dropdown list thru dataset

Hi,

Any idea how to fill a dropdownlist thru dataset

I done like this
ddLst1.DataSource = myDataSet
ddLst1.DataMember = myDataSet.Tables(0).Columns(1).Caption

ddLst1.DataValueField = myDataSet.Tables(0).Columns(0).Caption

but it is not working ; my dropdown list showing blanck

please help me
--
Regards

K R Lal
Nov 22 '05 #1
4 5898
You are close. You need to call the DataBind() method on your control.

-Andrew
"K R Lal" <la**@yahoo.com> wrote in message
news:#Q**************@tk2msftngp13.phx.gbl...
Hi,

Any idea how to fill a dropdownlist thru dataset

I done like this
ddLst1.DataSource = myDataSet
ddLst1.DataMember = myDataSet.Tables(0).Columns(1).Caption

ddLst1.DataValueField = myDataSet.Tables(0).Columns(0).Caption

but it is not working ; my dropdown list showing blanck

please help me
--
Regards

K R Lal

Nov 22 '05 #2
You are close. You need to call the DataBind() method on your control.

-Andrew
"K R Lal" <la**@yahoo.com> wrote in message
news:#Q**************@tk2msftngp13.phx.gbl...
Hi,

Any idea how to fill a dropdownlist thru dataset

I done like this
ddLst1.DataSource = myDataSet
ddLst1.DataMember = myDataSet.Tables(0).Columns(1).Caption

ddLst1.DataValueField = myDataSet.Tables(0).Columns(0).Caption

but it is not working ; my dropdown list showing blanck

please help me
--
Regards

K R Lal

Nov 22 '05 #3
lea

Private Sub DropDownList3_Load(ByVal sender As Object, ByVal e A
System.EventArgs) Handles DropDownList3.Load
DropDownList3.Items.Clear()
Dim ds As New ListItem()
Dim con As String = "Provider=Microsoft.Jet.OLEDB.4.0;Dat
Source=database.mdb" ( Change this to ur connection string)
Dim dc As New OleDbConnection(con)
Dim strSQL As String = "SELECT PurposeFunction FRO
[Contribution]" (change this to ur field name and table name)
Dim cmd As New OleDbCommand(strSQL, dc)
dc.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader()
While dr.Read()
ds.Text = dr(0)
If DropDownList3.Items.Contains(ds) = False Then
DropDownList3.Items.Add(dr(0))
End If
End While
dc.Close()
----------------------------------------------------------------------------------------------------------------------------------------------------
this code is not set thru dataset, but it's actually work and n
duplication! Hope this can help yo

--
le
-----------------------------------------------------------------------
lea's Profile: http://www.msusenet.com/member.php?userid=156
View this thread: http://www.msusenet.com/t-187044956

Nov 22 '05 #4
lea

Private Sub DropDownList3_Load(ByVal sender As Object, ByVal e A
System.EventArgs) Handles DropDownList3.Load
DropDownList3.Items.Clear()
Dim ds As New ListItem()
Dim con As String = "Provider=Microsoft.Jet.OLEDB.4.0;Dat
Source=database.mdb" ( Change this to ur connection string)
Dim dc As New OleDbConnection(con)
Dim strSQL As String = "SELECT PurposeFunction FRO
[Contribution]" (change this to ur field name and table name)
Dim cmd As New OleDbCommand(strSQL, dc)
dc.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader()
While dr.Read()
ds.Text = dr(0)
If DropDownList3.Items.Contains(ds) = False Then
DropDownList3.Items.Add(dr(0))
End If
End While
dc.Close()
----------------------------------------------------------------------------------------------------------------------------------------------------
this code is not set thru dataset, but it's actually work and n
duplication! Hope this can help yo

--
le
-----------------------------------------------------------------------
lea's Profile: http://www.msusenet.com/member.php?userid=156
View this thread: http://www.msusenet.com/t-187044956

Nov 22 '05 #5

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

Similar topics

2
by: K R Lal | last post by:
Hi, Any idea how to fill a dropdownlist thru dataset I done like this ddLst1.DataSource = myDataSet ddLst1.DataMember = myDataSet.Tables(0).Columns(1).Caption ddLst1.DataValueField =...
3
by: ali poursadri | last post by:
Hi, I want to fill my list box from a dataset in c#. I use adapter and fill command and bind it to a listbox, but it is very slow for large data about 500000 records. How can I view this list...
5
by: Helixpoint | last post by:
Here is my code: Dim availMach As New ASPNETProduct.machinedb() Dim dstMachList As DataSet dstMachList = availMach.GetAvailMach(theSearchVal, theSearchBy, theMachCode1, theSearchView,...
4
by: Paul | last post by:
I have a dropdown list box and a button on a web form, the autopost back is false for the dropdown list box and button. When the button is pushed the selection in the dropdownlist box is lost,...
2
by: JIM.H. | last post by:
Hello, I have a dropdown list, updated through a dataset. After bind, I use this to add extra item to my dropdown list. myDropDownList.Items.Add(“Item1”), I can remove that by using...
5
by: david | last post by:
I have a question in the following. Any one could give me a help? Thanks David The dataset is declared and created at Class level. My source code is here: Private Sub...
1
by: Ed Chiu | last post by:
Hi, I have 2 dropdown lists on an ASP.Net page, the first is a list of states of US, the second is City list. When user selects a state, the web page does a postback, create a DB connection and...
4
by: K R Lal | last post by:
Hello all, how can i fill the data to combo box from dataset please help me. regards lal
10
by: dauphian | last post by:
Hello, I am new to .net and am trying to build a report application that queries 4 different tables based on a id, and I need to return them in the same table for easy viewing. Basically, I...
2
by: Lair | last post by:
I am creating a page that has three to four databound dropdown lists. Each one is has different data sometimes from the same table but with a different where clause. What is the best way to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.