.net - How to Show primary key data? -


i have 2 tables: transactions , accounts.

transaction has foreign key idaccount accounts table.

i assign datasource property of datasource property of datagridview transactions table.

i want accounts.description insead of idaccount in datagridview.

what must do?

there solution problem offered here involves doing custom code inspect each property , determine if belongs main bound object or child object.

this looks solution except doesn't support editing or sorting based on these properties.

another approach (which recommend since simpler) introduce accountdescription property transaction object.

public class transaction {     private account _account      public string accountdescription     {         { return _account.description; }         set { _account.description = value; }     } } 

you might need implement custom inotifypropertychanged code databinding works nicely.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -