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

Access datasourcerow from a joined table

1 Answer 29 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 26 Feb 2013, 04:43 PM
Using SQLDataSource, so please provide a solution with this rather than an alternative unless it cannot be done. Thanks

TableA and TableB from the same database

My "ItemsRequested" for the combobox has this string setup and it works fine.

Dim sql as string = "SELECT TOP 10 B.serialnumber,  A,column, B,Column FROM DB.dbo.TableA A, DB.dbo.TableB B Where B.column LIKE'" + e.Text + "%' and B.column!='CL' order by B.column"

My problem is on the "ItemBound" method.

e.Item.Text = e.Item.Attributes("column") + ", "+e.Item.Attributes("column") + ", " +e.Item.Attributes("column")

The column name has to be the colum from TableB.  In other words  B.Colmn.
Putting in B.Column of course won't work as follows...
e.Item.Text = e.Item.Attributes("B.serialnumber") + ", "+e.Item.Attributes("column") + ", " +e.Item.Attributes("column")

So with this join involved how do a pull this information specifically from the joined table column? B.Column

Thanks!

1 Answer, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 01 Mar 2013, 01:32 PM
Hi Greg,

Try to change the SQL string like the following:

Dim sql as string = "SELECT TOP 10 B.serialnumber,  A.Column AS [columnA], B.Column AS [columnB] FROM DB.dbo.TableA A, DB.dbo.TableB B Where B.column LIKE'" + e.Text + "%' and B.column!='CL' order by B.column"
then you should be able to access the columns from the joined tables:
e.Item.Text = e.Item.Attributes("columnA") + ", "+e.Item.Attributes("columnB") + ", " +e.Item.Attributes("column")


Greetings,
Hristo Valyavicharski
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ComboBox
Asked by
Greg
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Share this question
or