Click here to Skip to main content
15,909,193 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to display the data in the data grid view.the response i am getting in the json format .how to convert the data from json format to data grid view data to display the data
Posted

extract json data to datatable then assign datatable to datagridview's datasource property
http://stackoverflow.com/questions/11981282/how-to-convert-json-to-datatable-in-c-sharp[^]
http://james.newtonking.com/pages/json-net.aspx[^]
Happy Coding!
:)
 
Share this answer
 
 
Share this answer
 
Try This one :)

C#
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://your json URL");

                //&tracking_number=" + txtttnumber.Text + "&courier=" + ddlcourier.SelectedValue

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream receiveStream = response.GetResponseStream();
                    StreamReader readStream = null;

                    if (response.CharacterSet == null)
                        readStream = new StreamReader(receiveStream);
                    else
                        readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
                    //  List<string> list = new List<string>();
//Convert JSON object into String
                    string data = readStream.ReadToEnd();
//Convert JSON object into Dictionary
 Dictionary<string, object> dict = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(data);

                  
//Convert into variable
                    var GridData= dict["checkpoints"];

GridView1.DataSource=GridData;
GridView1.DataBind();

//
//


                         }
 }
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900