Solved

wcf, asp.net, jquery / ajax call

Posted on 2015-02-06
1
128 Views
Last Modified: 2015-03-12
ServiceRef.QuoteServiceClient i = new ServiceRef.ProQuoteServiceClient();
string result = i.GetModelListJSon("088", "12345");
Response.Write(result);

I have above web service(jquery/ajax) called and result below string.

{"PackageKey":null,"PackageNo":1,"TotalPackages":1,"Status":"Ok","Data":"[{\"ModelNo\":\"D7L4U\",\"ModelName\":\"DDA PROGRAM 01/11\",\"NetPrice\":0.0,\"ListPrice\":1.0,\"AMDD\":1.0},]"}

How can I bind(using asp.net/c#) it with asp:dropdown with model no only as value and text?


{"PackageKey":null,"PackageNo":1,"TotalPackages":1,"Status":"Ok","Data":"[{\"ModelNo\":\"DDADTR17L4DU\",\"ModelName\":\"DDA PROGRAM 01/11\",\"NetPrice\":0.0,\"ListPrice\":1.0,\"AMD\":1.0},]"}
0
Comment
Question by:ITsolutionWizard
1 Comment
 
LVL 25

Accepted Solution

by:
apeter earned 500 total points
ID: 40602930
You have to strip out the data part and bind that list to your control. But why that list coming as a string ? . Your output should be like below.

{"PackageKey":null,"PackageNo":1,"TotalPackages":1,"Status":"Ok","Data":[{"ModelNo":"DDADTR17L4DU","ModelName":"DDA PROGRAM 01/11","NetPrice":0.0,"ListPrice":1.0,"AMD":1.0}]}

Then you serialize them back to below classes using json serialised. Datum can be used to bind to your control

public class Datum
{
    public string ModelNo { get; set; }
    public string ModelName { get; set; }
    public double NetPrice { get; set; }
    public double ListPrice { get; set; }
    public double AMD { get; set; }
}

public class RootObject
{
    public object PackageKey { get; set; }
    public int PackageNo { get; set; }
    public int TotalPackages { get; set; }
    public string Status { get; set; }
    public List<Datum> Data { get; set; }
}
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question