Link to home
Start Free TrialLog in
Avatar of badrhino
badrhinoFlag for United States of America

asked on

Binding to a Drop Down box with a sql server datasource

I'm starting to play with JQuery a little and I would like to bind data from a sql server to a drop down box (just to learn how).  The code behind has to be in

I have looked at several examples on the web but they either C# or and don't work/aren't complete.  Does anyone know of a good walkthrough that I can play with?

Thanks in advanced!
Avatar of Rajar Ahmed
Rajar Ahmed
Flag of India image

Try these,

Approach 1 . Binding dropdown using

Protected Sub Button1_Click1(sender As Object, e As EventArgs)

dim str As String = "Data Source=.;uid=sa;pwd=wintellect;database=rohatash"

	Dim con As New SqlConnection(str)
Dim anyFilter as string= ""
	Dim cmd As New SqlCommand("select textColumn,valueColumn from UserDetail where id = '" & anyFilter & "'", con)

	Dim Adpt As New SqlDataAdapter(cmd)

	Dim dt As New DataTable()


	ddl1.DataSource = dt


End Sub

Open in new window

Approach 2 : Using SqlDatasource control .
Binding Dropdown using SqlDatasource control without codebehind .
Sqldatasource connectionstring parameter is configured in web.config file .
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    connectionString="Data Source=serverName;Initial 
    Catalog=Northwind;Persist Security Info=True;User 

Open in new window

More Info Regarding Connection string ,

Avatar of badrhino


This works great for server side code, but how do you do it with JQuery?
Avatar of Rajar Ahmed
Rajar Ahmed
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect. Thanks!