开发者

ObjectDataSource direct binding

开发者 https://www.devze.com 2023-01-31 19:22 出处:网络
I have 2 SQL tables with a single relationship. Table A: Id, ApplicationID, Message. Table B: Id, ApplicationName.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号