Solved

wcf, asp.net, jquery / ajax call

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

774 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