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 vb.net.
I have looked at several examples on the web but they either C# or vb.net and don't work/aren't complete. Does anyone know of a good walkthrough that I can play with?
Thanks in advanced!
jQueryWCFVisual Basic.NET
Last Comment
badrhino
8/22/2022 - Mon
Rajar Ahmed
Try these,
Approach 1 . Binding dropdown using vb.net
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() Adpt.Fill(dt) ddl1.DataSource = dt ddl1.DataBind()ddl1.DataTextField="textColumn"ddl1.DataValueField="valueColumn"End Sub
Approach 1 . Binding dropdown using vb.net
Open in new window
Approach 2 : Using SqlDatasource control .Binding Dropdown using SqlDatasource control without codebehind .
http://asp-net-example.blogspot.in/2008/12/aspnet-sqldatasource-example-using.html
Sqldatasource connectionstring parameter is configured in web.config file .
Open in new window
More Info Regarding Connection string ,
http://msdn.microsoft.com/en-us/library/ms178411(v=vs.100).aspx
Meeran03