This is a migrated thread and some comments may be shown as answers.

Using a self joined table in a query for RADGrid

2 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jürg
Top achievements
Rank 1
Jürg asked on 15 Sep 2014, 03:51 PM
Hi all

I have an RADGrid which is bound to an ObjectDataSource. I use an SQLDataReader to read a self joined table from the database. After having tried several sql statements with table aliases, I ended up with the following (simplified) sql statement:

Select F.SysID, F.Companyname, F.Address, K.sysID As ConsSysID, K.Companyname As ConsCompanyname, K.Address As ConsAddress From Company As F Left Outer Join Company As K on F.ConsolidatedWithID = K.SysID

In cases where a company belongs to another company (holding structure), the field ConsolidatedWithID contains the SysID of the holding company it belongs to. When reading the SqlDataReader, objDataReader("ConsCompanyname") returns the correct value from the database. However in my RADGrid the GridBoundColumn with DataField = "ConsCompanyname" doesn't show any value.

Any help appreciated. Thanks.

Jürg

2 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 18 Sep 2014, 11:38 AM
Hi Jürg,

The binding that you described should work correct. If the data field is accessible from the result data table, it will be shown in the grid. You could bind asp GridView in order to dismiss or confirm if the problem in the RadGrid or in your DataSource.

Regards,
Vasil
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jürg
Top achievements
Rank 1
answered on 19 Sep 2014, 03:11 PM
Hi Vasil

Thank you for your input. After having bound everything to asp GridView, I found that the problem was caused by the objects bound with the object data source. After having corrected those object definitions, everything is working now.

Thank you for your support and sorry for the confusion.

Jürg
Tags
Grid
Asked by
Jürg
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Jürg
Top achievements
Rank 1
Share this question
or