Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on winform app through which I am fetching my result from api link
"http://lms-result-app.herokuapp.com/2019-ag-6091". i want to show this json data in grid view in winform I have success in fetching data using rest sharp NuGet and display it on richtextbox.
but I am unable to show it on grid view

What I have tried:

private void button1_Click(object sender, EventArgs e)
       {
           RestClient restClient = new RestClient();
           RestRequest restRequest = new RestRequest(String.Concat("http://lms-result-app.herokuapp.com/2019-ag-6091"), Method.GET);
           IRestResponse restResponse = restClient.Execute(restRequest);
           if (restResponse.StatusCode == System.Net.HttpStatusCode.OK)
           {
               this.dataGridView1.DataSource = restResponse;
           }
       }
Posted
Updated 24-Apr-22 17:41pm
Comments
PIEBALDconsult 24-Apr-22 13:09pm    
Is the data tabular in nature?
Populate a DataTable with it.
muhammad abubakar 2022 10-May-22 4:03am    
it does not do anything in grid view

1 solution

You need to deserialize your json data before you can use it as a source object for your grid.

For details on how to deserialize (create one based on your json data): Convert JSON String to Object in C#[^]

Code would be like:
if (restResponse.StatusCode == System.Net.HttpStatusCode.OK)
{
   // 1. Deserialize response here 
   //

   // 2. Assign the new object (say objRestResponse) into which json was deserialized
   this.dataGridView1.DataSource = objRestResponse;
}
 
Share this answer
 
Comments
muhammad abubakar 2022 10-May-22 4:04am    
it gives no response in the grid view

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