Bind CheckBoxList using AJAX

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AnaOlinto
    New Member
    • Aug 2009
    • 4

    Bind CheckBoxList using AJAX

    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:

    Code:
    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!

    Ana
    Last edited by debasisdas; Aug 22 '09, 07:49 PM. Reason: moved to vb.net section.
Working...