ObjectDataSource direct binding
I have 2 SQL tables with a single relationship. Table A: Id, ApplicationID, Message. Table B: Id, ApplicationName. Relatio开发者_开发知识库nship: A.ApplicationID = B.Id
I want to use a objectdatasource to bind them directly to a gridview but i want to show ApplicationName instead of ApplicationID.
How can i do that?
Thank U ALL.
What sort of data access are you using? Ado.net? Linq2Sql? Entity Framework?
A sample would require data access which would query both tables and provide the data for the selectMethod of the object datasource.
listbox.DataBindings.Add("ValueMember",DataSource ,"ApplicationID");
listbox.DisplayMember.Add("DisplayMember",DataSource,"ApplicationName");
On a TextBox or Label or what ever control, you can use Tag
property to "ValueMember"
and Text property as DisplayMember
, or create your own.
精彩评论