Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Using the GET method to show banks from the DB in the DataGridview but it doesn't show anything. Why?


What I have tried:

<pre>namespace BankData
{
    [Newtonsoft.Json.JsonObject("ResultData")]
    public class ResultData
    {
        public string Name { get; set; }
        public List<Bank> RresultObject { get; set; }

        public string UUId { get; set; }

         [Newtonsoft.Json.JsonProperty("FirstName")]
        public string FirstName { get; set; }

        public string LastName { get; set; }

        public string address { get; set; }
       
        public string tel { get; set; }

        public string Marital_status { get; set; }

        public string Occupation { get; set; }

        public string PayIN { get; set; }
    }
}

return all banks:
public ResultData getAllBank()
{
    ResultData resultData = new ResultData();
    resultData.Name = "AllBank";
    List<Bank> banks = new List<Bank>();
    banks.AddRange(DataBaseService.getBank());
    resultData.RresultObject = banks;
    return resultData;
}

my requset:
async Task<object> GetBanktAsync(string path)
{
    HttpClient client = new HttpClient();
    HttpResponseMessage response = await client.GetAsync(path);
    object result=null;
    if (response.IsSuccessStatusCode)
    {
        result = response.Content.ReadAsAsync<object>().Result;
    }
    return result;
}

Then Load Manager:
        private async void Manager_Load(object sender, EventArgs e)
        {

            try
            {
                var resultString = await GetBanktAsync("http://localhost:35799/bank");
            
                var deserializeObject = Newtonsoft.Json.JsonConvert.DeserializeObject<object>(resultString.ToString());
                dataGridViewBank.DataSource = deserializeObject;
            }
            catch (Exception ex)
            {

            }
Posted
Comments
F-ES Sitecore 4-May-18 4:25am    
Use the debugger to work out what your code is doing. Your "catch" block also means it's possible your code is throwing an exception but you're ignoring it. Exceptions are there to let you know what the problem is.

1 solution

Using the GET method to show banks from the DB in the DataGridview but it doesn't show anything. Why?
 
Share this answer
 

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