473,395 Members | 2,713 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,395 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 5897
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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,...

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.