honag luc

honag luc

  • NA
  • 123
  • 9.1k

Load data api form 3 table

Mar 2 2023 11:14 AM

Hello everyone i have api data is 3 data tables like in datagridview, above data is load from 3 tables are room, location and devices. Here is the code that connects to the server and loads the data, but at the location and device it gets the code (unwanted). now i want not to display the code, but the text as shown, hope everyone can help.

public class grpcStudent
{
    static SysSetting setting = SysSetting.GetInstance;

    static string url;

    static grpcStudent()
    {
        if (string.IsNullOrWhiteSpace(url))
            url = setting.IpGrpc + ":1780";//ip and port
    }
    public async Task<StudentIndexRS> getStudent(Student.QueryRQ query)
    {
        StudentIndexRS result = new StudentIndexRS();
        try
        {
            GrpcChannel channel = GrpcChannel.ForAddress(url);
            var client = new Student.StudentClient(channel);
            result = client.IndexAsync(query).ResponseAsync.Result;
        }
        catch (Exception ex)
        {
            string str = ex.Message;
        }
        return result;
    }
}
private void loadDataStudent()
{
    StudentIndexRS result = apiStudent.getStudent(new QueryRQ()).Result;

    if (result == null)
    {
        MessageBox.Show("dont get data", Program.Setting.Language.GetString("captionerror"), MessageBoxButtons.OK, MessageBoxIcon.Error);
        return;
    }
    else if (result.Status != 200)
    {
        MessageBox.Show(result.Error, Program.Setting.Language.GetString("captionerror"), MessageBoxButtons.OK, MessageBoxIcon.Error);
        return;
    }
    else
    {
        grdStudent.DataSource = result.Data;
        grdStudent.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        grdStudent.AutoResizeColumns();
        grdStudent.AllowUserToResizeColumns = true;
    }
}

 


Answers (3)