I have a Database table that I want to display in a DataGridView. However, it has several foreign keys and I don’t want to show the integer that represents the other Table to the user.
I have this DataTable with a column userId I have another DataTable with a column id, and a column username
I want the DataGridView to show the username instead of userId where the userId = id.
How can I do this? I also have to do this on several columns in the same table to be displayed.
edit: windows forms, not web forms.
How are you populating the DataTable? You can specify custom SQL with the joins and appropriate columns to the .SelectCommand of a DataAdapter or specify the custom SQL in the .CommandText of a xxxCommand object.
Eg
Or
Or as has been mentioned, you could create a view or storedproc in your database and call that.