I have written a WCF service for retrieving data from database. and i am storing that in to a data set.then I am calling that service through jQuery service is executing fine and retrieving data also.But Retrieved data is in XML format how can i convert this XML format to normal table to bind grid view using Jquery and also the problem is while i am binding retrieved data set data to grid view using Jquery i am not getting any data in grid view .how can i solve this?Please any one can help me....
and my Jquery Function is
var Type;
var Url;
var Data;
var ContentType;
var DataType;
var ProcessData;
function CallService() {
$.ajax({
type: Type,
url: Url,
data: Data,
contentType: ContentType,
dataType: DataType,
processdata: ProcessData,
success: function(msg) {
ServiceSucceeded(msg);
},
error: ServiceFailed
});
}
function ServiceFailed(result) {
alert('Service call failed: ' + result.status + '' + result.statusText);
Type = null; Url = null; Data = null; ContentType = null; DataType = null; ProcessData = null;
}
function WCFJSON() {
Type = "POST";
Url = "Service.svc/GetPatientdetails";
Data = '{"Id": ""}';
ContentType = "application/json; charset=utf-8";
DataType = "json"; ProcessData = true;
CallService();
}
function ServiceSucceeded(result) {
if (DataType == "json") {
resultObject = result.GetPatientdetailsResult;
var row = $("[id*=gvpatient] tr:last-child").clone(true);
$("[id*=gvpatient] tr").not($("[id*=gvProducts] tr:first-child")).remove();
for (var i = 0; i < resultObject.d.length; i++) {
$("td", row).eq(0).html(resultObject.d[i].lblID);
$("td", row).eq(1).html(resultObject.d[i].lblPatientId);
$("td", row).eq(2).html(resultObject.d[i].lblIsPatient);
$("td", row).eq(3).html(resultObject.d[i].lblFirstname);
$("td", row).eq(4).html(resultObject.d[i].lblMiddleinti);
$("td", row).eq(5).html(resultObject.d[i].lblLastname);
$("td", row).eq(6).html(resultObject.d[i].lblBirthdate);
$("td", row).eq(7).html(resultObject.d[i].lblMobileno);
$("td", row).eq(8).html(resultObject.d[i].lblCity);
$("[id*=gvpatient]").append(row);
row = $("[id*=gvpatient] tr:last-child").clone(true);
}
}
}
function ServiceFailed(xhr) {
alert(xhr.responseText);
if (xhr.responseText) {
var err = xhr.responseText;
if (err)
error(err);
else
error({ Message: "Unknown server error." })
}
return;
}
$(document).ready(
function() {
WCFJSON();
}
);
and my service function
public DataSet GetPatientdetails()
{
string Name = string.Empty;
// Getting Details from database
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("sp_per_GetPatientDetails", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = cmd;
da.Fill(ds);
//SqlDataReader dr = cmd.ExecuteReader();
//while (dr.Read())
//{
// Name = dr["Per_Firstname"].ToString();
//}
con.Close();
//return Name;
return ds;
}