Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

wcf, asp.net, jquery / ajax call

Posted on 2015-02-06
1
Medium Priority
?
146 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 25

Accepted Solution

by:
apeter earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

721 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