Connecting Tech Pros Worldwide Help | Site Map

Bind CheckBoxList using AJAX

Newbie
 
Join Date: Aug 2009
Posts: 4
#1: Aug 14 '09
Hi,

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:

Expand|Select|Wrap|Line Numbers
  1. Dim DatabaseConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("MyServer").ConnectionString)
  2.         Dim selectSQL As String = "SELECT Name, Id FROM myTable"
  3.         Dim selectCMD As New SqlCommand(selectSQL, DatabaseConnection)
  4.         selectCMD.Parameters.Add(New SqlParameter("@name", SqlDbType.VarChar))
  5.         selectCMD.Parameters("@name").Value = MyTextBox.Text
  6.  
  7.         Dim adapter As New SqlDataAdapter
  8.         Dim dTable As New DataTable
  9.         adapter.SelectCommand = selectCMD
  10.         adapter.Fill(dTable)
  11.  
  12.         MyCheckBoxList.DataSource = dTable
  13.         MyCheckBoxList.DataTextField = "Name"
  14.         MyCheckBoxList.DataValueField = "Id"
  15.         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!

Ana
Reply

Tags
ajax, bind, checkboxlist