I'm new using AJAX and I'm developing a page where I need to populate a CheckBoxList based on what the user types (it's like an AutoSuggest). I don't know how to bind the checkboxlist from the database using AJAX.
My code in VB.NET is something like this:
Dim DatabaseConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("MyServer").ConnectionString) Dim selectSQL As String = "SELECT Name, Id FROM myTable" Dim selectCMD As New SqlCommand(selectSQL, DatabaseConnection) selectCMD.Parameters.Add(New SqlParameter("@name", SqlDbType.VarChar)) selectCMD.Parameters("@name").Value = MyTextBox.Text Dim adapter As New SqlDataAdapter Dim dTable As New DataTable adapter.SelectCommand = selectCMD adapter.Fill(dTable) MyCheckBoxList.DataSource = dTable MyCheckBoxList.DataTextField = "Name" MyCheckBoxList.DataValueField = "Id" MyCheckBoxList.DataBind()
I think the binding in Ajax would be similar to this, but I don't know. Please, can anyone help me with this?
Thanks a lot!