ASP.NET - Need help in displaying value in gridview from two tables.

Asked By Masuma Aktar on 28-Feb-09 06:13 AM
Hi all,
I need help  how to display value from two tables in gridview. I have two tables FeaturedProducts and Products.FeaturedProduct fields are:productid,featuretext,saleprice and Products fields are:productid,catid,name,shorttext,longtext,price,thumbnail,image

I want to display productid,featuretext,saleprice from FeaturedProduct table and name and price from products table inside the gridview.I know this join query but how to do this thru setting like choose data Source->New Data Source.Please somebody help me.

Thanks,
Masum


Vasanthakumar D replied to Masuma Aktar on 28-Feb-09 06:40 AM

Hi,

try the below one..

1. Add Sql datasource control from tool box

2. Select Configure datasource

3. In "Choose your Data connection" window select the databaset

4. Save the connection string

5. And in next window select "Specify custom sql statment or stored porcedure"  radio button

6. Clik next

7. In next winodw you can write your own query or build the query from Query builder

8. Click Next , finish.

try this

sri sri replied to Masuma Aktar on 28-Feb-09 06:51 AM
hi,

try the following query for inner join

USE pubs
SELECT p.pub_id, p.pub_name, p.state, a.*
FROM publishers p
INNER JOIN authors a
ON p.city = a.city
ORDER BY a.au_lname ASC, a.au_fname ASC