title: Add checkboxs into Checkboxlist using Jquery ajax method in asp.net
body: <p>Add checkboxes into checkboxlist.</p>
  
  <p>For eg: I am passing dataset value as "1001","1002","1003","1004","1005" and get this value as XML using GetXml() function.</p>
  
  <p>The above value, will for  5 checkboxes separately and add into checkbox list. </p>
  
  <p><strong>Default.apsx.vb</strong> </p>
  
  <pre><code>&lt;WebMethod()&gt; _
      Public Shared Function returnData() As String
  
          Dim dsUtil As New DataSet
          Dim lstSQL As String
          Dim fdat, tdat, detai, valG, sta As String
          Try
              fdat = "20140317"
              tdat = "20140318"
              detai = "College"
              valG = "Y"
              sta = "2"
  
              lstrSQL = ("Exec SP_College '" &amp; fdat &amp; "','" &amp; tdat &amp; "','" &amp; detai &amp; "','" &amp; valG &amp; "','" &amp; sta &amp; "'")
              _Command = New SqlCommand(lstSQL)
  
              Return GetDataset(_Command).GetXml()
          Catch Ex As Exception
              Throw New Exception("Error " &amp; Ex.Message)
          End Try
          'Return ms
      End Function
  
  
  Public Shared Function GetDataset(ByVal tSQLQuery As SqlCommand) As DataSet
  
          Dim ds As New DataSet
          cn = New SqlConnection("Data Source=localhost; Initial Catalog = master;uid=sa;pwd=sa;")
          Try
              cn.Open()
              Dim da As New SqlDataAdapter(_Command)
  
              _Command.CommandType = CommandType.Text
              _Command.Connection = cn
  
              da.Fill(ds, "UTable")
  
              Return ds
  
          Catch oEx As Exception
              Throw New Exception("GetDataset-" &amp; oEx.Message)
          Finally
              ds.Dispose()
          End Try
  
      End Function
  
  
  
  **Default.aspx page**
  
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;input type="button" id="btnTray" value="Click here" onclick="checnkAjaxfn()"/&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;div id="divCheckBoxList" &gt;
  &lt;asp:CheckBoxList ID="chklistId" runat="server"&gt;
  &lt;/asp:CheckBoxList&gt;
   &lt;/div&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  
  **Ajax. Json script:**
  
  function checnkAjaxfn() {
           $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "Default.aspx/returnData",
            data:{},
            dataType: "json",
            success: OnSuccess,
            failure: function (response) {
             alert(response.d);
            },
            error: function (response) {
             alert(response.d);
            }
           });
         }
  
  
  function OnSuccess(response) {
          debugger;
          var xmlDoc = $.parseXML(response.d);
          var xml = $(xmlDoc);
          var xmlData = xml.find("UTable");
  
          var row = $("[id*=chklistId] tr:last-child").clone(true);
  
          $("[id*=chklistId] tr").remove();
  
          $.each(xmlData , function () {
           var xData = $(this);
           $("label", row).val($(this).find("Sys_ID").text());
           $("[id*=chklistId] tbody").append(row);
           row = $("[id*=chklistId] tr:last-child").clone(true);
          });
         }
  </code></pre>
  
  <p>The above does not add checkbox to checkboxlist.</p>
  
  <p>I debugged.
  when it reach </p>
  
  <blockquote>
    <p>$.each(xmlData , function () {</p>
  </blockquote>
  
  <p>this line, its come at end line.</p>
  
  <p>pls say how to generate checkbox inside checkboxlist</p>