Solved

wcf, asp.net, jquery / ajax call

Posted on 2015-02-06
1
121 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now