i am creating the simple crud system using asp.net ajax JSON, i created the function get all to retrieve the values from the all_data.aspx page as type as JSON. but I couldn't retrieve the data.what i tried so far i added below
Table Design
<table id="tbl-category" class="table table-responsive table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</table>
ajex function
function get_all() {
$('#tbl-category').dataTable().fnDestroy();
$.ajax({
url: 'all_data.aspx',
type: "GET",
dataType: "JSON",
success: function (data) {
$('#tbl-category').dataTable({
"aaData": data,
"scrollX": true,
"aoColumns": [
{ "sTitle": "fname", "mData": "fname" },
{ "sTitle": "age", "mData": "age" },
{
"sTitle": "Edit",
"mData": "id",
"render": function (mData, type, row, meta) {
return '<button class="btn btn-xs btn-success" onclick="get_category_details(' + mData + ')">Edit</button>';
}
},
{
"sTitle": "Delete",
"mData": "id",
"render": function (mData, type, row, meta) {
return '<button class="btn btn-xs btn-primary" onclick="RemoveCategory(' + mData + ')">Delete</button>';
}
}
]
});
},
record table consists of first name, age columns only here how to set this column as JSON type I don't know do it please some help me to do this i attached below what I tired so far
**all_data.aspx*
string sql = "select * from records";
SqlCommand cmd = new SqlCommand(sql, con);
con.Open();
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter();
da.Fill(dt);
string sql = "{\"fname\":\"fname\",\"age\":\"age\"}";
Response.Clear();
Response.ContentType = "application/json; charset=utf-8";
Response.Write(json);
Response.End();