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 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;
}
}
Tuhin PaulPosted Mar 2, 2023, 6:58 PM
To display the text instead of the code in the location and device columns, you need to modify the DataGridView control's columns' properties. Specifically, you need to set the DataPropertyName property of each column to the name of the corresponding property in the data source that contains the text value you want to display.
Assuming that the columns in the DataGridView are named "location" and "device," and the corresponding properties in the data source that contain the text values are also named "location" and "device," respectively, you can modify the code as follows:
the DataPropertyName property of the "location" and "device" columns is set to "location.text" and "device.text," respectively, assuming that the text values are stored in a property named "text" within the "location" and "device" objects. If the property names are different, you need to update the code accordingly.
Naimish MakwanaPosted Mar 2, 2023, 11:28 AM
If you are receiving list of object, then you can modify your list and select only specific column you want to display like below
Naimish MakwanaPosted Mar 2, 2023, 11:20 AM
What is the formate of data you are receiving in result.Data object ? Is this list of any class? can you share some sample data?