You can use ajax post for doing this. You have to create a web method and that web method should bring the value from database and you can use jquery to call that web method and in that web method you can construct your html table by using string builder and by using jquery you can bind your table inside a div.
Use this code carrefully
C# Code
[WebMethod]
public static string GetServices(string entry_id)
{
string HtmlData = string.Empty;
try
{
HtmlData = GetString();
}
catch (Exception ex)
{
/////
}
return HtmlData;
}
private static string GetString()
{
//write the code for bring value from database
DataTable table = new DataTable();//bring all your value in to this datatable
DataRowCollection drows = table.Rows;
StringBuilder HTML = new StringBuilder();
HTML.AppendLine("<table>");
foreach (DataRow dr in drows)
{
HTML.AppendLine("<tr>");
HTML.AppendFormat("<td>{0}</td>\n", dr["FieldName"]);
HTML.AppendLine("</tr>");
}
HTML.AppendLine("</table>");
HTML.AppendLine("</div>");
return HTML.ToString();
}
Jquery
Import the jquery library here
<script type="text/javascript">
$("#button").click(function(){
storeInfo();
});
function storeInfo() {
var elem_id = elem.attr('id');
var page_url = 'Pagename.aspx/GetServices';
$.ajax({
type: 'POST',
url: page_url,
data: "",
contentType: 'Application/json; charset=utf-8',
dataType: 'json',
success: function (details)
{ $("#storeInformation").html(details.d); }
});
return false;
}
});
</script>
Html Code
<div id="storeInformation">
</div>
Or use this
http://www.c-sharpcorner.com/uploadfile/farooque84/data-binding-from-dataset-to-html-table-in-net/[
^]