Here is my example to explain your scenario :-
1) Include the following references as mentioned below in the code behind :-
using System;
using System.Collections.Generic;
using System.Data;
using System.Web.Script.Serialization;
using System.Web.Services;
2) Created a new test data table for the fetching of data on page load as below :-
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
_dt.Columns.Add("ID");
_dt.Columns.Add("Name");
DataRow dr1 = _dt.NewRow();
dr1["ID"] = 1;
dr1["Name"] = "Smruti";
_dt.Rows.Add(dr1);
DataRow dr2 = _dt.NewRow();
dr2["ID"] = 2;
dr2["Name"] = "Ranjan";
_dt.Rows.Add(dr2);
}
}
3) Create a page method to return data from this DataTable in JSON formatted string as below :-
[WebMethod]
public static string GetData()
{
List<Dictionary<string, object>> dicRows = new List<Dictionary<string, object>>();
Dictionary<string, object> dicRow = null;
foreach (DataRow dr in _dt.Rows)
{
dicRow = new Dictionary<string, object>();
foreach (DataColumn col in _dt.Columns)
{
dicRow.Add(col.ColumnName, dr[col]);
}
dicRows.Add(dicRow);
}
JavaScriptSerializer objSerializer = new JavaScriptSerializer();
string sJSON = objSerializer.Serialize(dicRows);
return sJSON;
}
4) Now in aspx page add a reference to JS file & code to call the 'GetData' method through jQuery Ajax inside the head as below :-
<head runat="server">
<title></title>
<script src="jquery-2.0.3.js"></script>
<script type="text/javascript">
$(function () {
$("#btnTest").click(function () {
GetTestData();
});
});
function GetTestData() {
$.ajax({
type: "POST",
url: "../DataTableTestWithJQuery.aspx/GetData",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function (response) {
var result = JSON.parse(response.d);
$.each(result, function (index, obj) {
alert(obj.ID);
alert(obj.Name);
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
</script>
</head>
In the similar way you can get your Oracle DB data fetched as DataTable in client-side code in aspx.
Hope this will definitely of help to you.