Hi,
Please try below code to bind it.
HTML
<script type="text/javascript">
var x = 0;
$(function () {
var i = 1;
$.ajax({
type: "POST",
url: "Default.aspx/GetCountries",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var xmlDoc = $.parseXML(data.d);
var xml = $(xmlDoc);
var countries = xml.find("Country");
var htmlString = '';
$(countries).each(function (index) {
var country = $(this);
var col = 'collapse' + i;
htmlString += '<div class="panel panel-default" id="accordionpanel">';
htmlString += '<div class="panel-heading" id="head">';
htmlString += '<h2 class="panel-title">';
htmlString += '<a id="' + x + '" data-toggle="collapse" class="collapsed" data-parent="#accordion" href="#' + col + '">' + country.find("Name").text() + '</a>';
htmlString += '</h2></div>';
htmlString += '<div id="' + col + '" class="panel-collapse collapse">';
htmlString += '<div clas="panel-body">' + country.find("CountryDescription").text() + '</div>';
htmlString += '<div class="panel-footer" style="text-align: center;">';
htmlString += '<div class="row">';
htmlString += '<div class="col-sm-4"><input type="button" class="btn btn-primary shadow" style="color:white;" value="Download sample Document"/></div>';
htmlString += '<div class="col-sm-4"><input type="button" class="btn btn-info" onclick="uploadpopup(this,' + x + ')" value="Upload Filled Document"/></div>';
htmlString += '<div class="col-sm-4"><input type="button" class="btn btn-success" value="Download New Document"/></div>';
htmlString += '</div></div></div>';
i = i + 1;
x = x + 1;
});
var acc = $('#accordion').html(htmlString);
}
});
});
</script>
<div id="accordion">
</div>
C#
[WebMethod]
public static string GetCountries()
{
DataSet ds = new DataSet();
DataTable dt = new DataTable("Country");
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)) ,
new DataColumn("CountryDescription", typeof(string))});
dt.Rows.Add(1, "United States", "English");
dt.Rows.Add(2, "India", "Hindi");
dt.Rows.Add(3, "France", "French");
ds.Tables.Add(dt);
return ds.GetXml();
}
I hope this will help you out.