Click here to Skip to main content
13,557,962 members
Rate this:
Please Sign up or sign in to vote.
See more:
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;
         //Generic function to call AXMX/WCF  Service
         function CallService() {
                 type: Type, //GET or POST or PUT or DELETE verb
                 url: Url, // Location of the service
                 data: Data, //Data sent to server
                 contentType: ContentType, // content type sent to server
                 dataType: DataType, //Expected data format from server
                 processdata: ProcessData, //True or False
                 success: function(msg) {//On Successfull service call
                 error: ServiceFailed// When Service call fails

         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() {
            // var uesrid = "2";
             Type = "POST";
             Url = "Service.svc/GetPatientdetails";
             Data = '{"Id": ""}';
             ContentType = "application/json; charset=utf-8";
             DataType = "json"; ProcessData = true;

         function ServiceSucceeded(result) {

             if (DataType == "json") {

                 resultObject = result.GetPatientdetailsResult;

//                 for (i = 0; i < resultObject.length; i++) {
//                     alert(resultObject);
//                                 }

                   var row = $("[id*=gvpatient] tr:last-child").clone(true);
                //remove the dummy row we have created
                $("[id*=gvpatient] tr").not($("[id*=gvProducts] tr:first-child")).remove();
                for (var i = 0; i < resultObject.d.length; i++) {
                    //Set product attributes to the row and add it to the gridview
                    $("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);
                    //get the copy of the last row again.
                    row = $("[id*=gvpatient] tr:last-child").clone(true);




         function ServiceFailed(xhr) {
             if (xhr.responseText) {
                 var err = xhr.responseText;
                 if (err)
                     error({ Message: "Unknown server error." })

         function() {

and my service function

public DataSet GetPatientdetails()

string Name = string.Empty;
// Getting Details from database
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
SqlCommand cmd = new SqlCommand("sp_per_GetPatientDetails", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = cmd;
//SqlDataReader dr = cmd.ExecuteReader();
//while (dr.Read())
// Name = dr["Per_Firstname"].ToString();

//return Name;
return ds;

Posted 6-Feb-13 22:42pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180515.1 | Last Updated 7 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100