0

I have a gridview that pulls from an sqldatasource, this sql datasource pulls from a table called survey, lets say that this survey table has : survey_id, survey_name, survey_description, and category_id. The category ID is a foreign key referring to a category table. the category table has category_id, name and description. Is there a way i can replace the category_id in the gridview and take instead the name where its ID is equal to the ID in the survey table?

4

2 に答える 2

1

このMSSQLコマンドを試してください

SELECT SR.survey_id, SR.survey_name, SR.survey_description,CA.name
FROM Tbl_Survey SR
INNER JOIN Tbl_Category CA 
ON SR.category_id.Id=CA.category_id;
于 2012-11-30T04:41:10.727 に答える
1

Yes, you can! You will need to change the SelectCommand for your SQLDataSource so that you are inner joining on the category table. You can then select the name from the category table, and bind it to the gridview.

于 2012-11-30T04:28:03.383 に答える