Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to select data from to table and show them in one gridview how i can do this

comment: one column of one table is forien key of another table.
Posted
Comments
I am not clear about the requirement. Can you please explain ?
Do you want to simply bind data from database to one Gridview ?
adriancs 8-Nov-12 9:34am    
select * from table1 inner join table2 on table1.someid = table2.id;

If you've already got a foreign key relationship you can create a view to join the tables. Assuming you're using SQL Server you can follow this guide:

Overview of Views in SQL Server 2005[^]

Then perform a select on the view as you would with any other table and databind the result to your GridView.
 
Share this answer
 
Comments
f.sarikhani 8-Nov-12 6:14am    
i want in c# with checking variables do this!!
first you can make a view in sql server that conataining one or more table that you want .for example tou can have two table by relation in a view and select your field from two table.
ok now you have a view in sql server thats contain your field;
and now you must go to your application and make a datagrideview ,and then in datagrideview tasks select choosedatasource and select your view.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900