We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

2 dropdownlist

Thread ID:

Created:

Updated:

Platform:

Replies:

67003 Aug 7,2007 06:41 AM Oct 8,2007 02:33 AM ASP.NET Web Forms (Classic) 1
loading
Tags: FAQ
Saqer
Asked On August 7, 2007 06:41 AM

hi

I hope some one help me , i use two dropdownlist in the same webform and each DDL gets data from differents tables SQL database. How can i write VB code

Poornima Joy Balan [Syncfusion]
Replied On October 8, 2007 02:33 AM

Hello,

The following code snippet helps you to add the data's from different table to DDL

Dim connString As String = "Provider=SQLOLEDB.1;User ID=yourid;Password=yourpassword;Persist Security Info=True;Network Address=yourIP;Initial Catalog=databasename"
Dim conn As New OleDbConnection(connString)
conn.Open()
Dim cmd As New OleDbCommand("select * from table1", conn)
cmd.CommandTimeout = 180

Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet()
da.Fill(ds)
List1.DataSource = ds.Tables(0)
List1.DataTextField = "Empname"
List1.DataValueField = "Empname"
List1.DataBind()

Dim cmd2 As New OleDbCommand("select * from table2", conn)
cmd2.CommandTimeout = 180

Dim da2 As New OleDbDataAdapter(cmd)
Dim ds2 As New DataSet()
da2.Fill(ds2)
List2.DataSource = ds.Tables(0)
List2.DataTextField = "category_id"
List2.DataValueField = "cname"
List2.DataBind()
conn.Close()

Let me know, any further queries.

Regards,
Poornima

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;