Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have tables database
1- payout_transcation
2- payout_master
i want data from both this tables in a single gridview or datagrid

can i do that...
Posted
Comments
Nandakishore G N 31-Jan-13 0:55am    
form a view of both the tables and bind it to the gridview.

Hello Sumit,

You can use Join to fetch the data from two tables

Go To : SQL Join

Hope it will help you.
 
Share this answer
 
How these tables are related... means relationship

if the payout_transcation table contains Forienkey relationship from payout_master, then
1) write a query joining 2 tables. Then bind the resultset to DataGrid or GridView
or
2) Create a view on both table and then query the view and bind the resultset to DataGrid or GridView

Please find the following query for sample
SQL
SELECT PT.*, PM.* FROM payout_transcation AS PT INNER JOIN payout_master AS PM ON PT.<forienkey> = PM.<primaykey>
</primaykey></forienkey>

Hope it helps you
Happy Coding :)
 
Share this answer
 
Join the 2 tables and bind the result to your grid view.
 
Share this answer
 
C#
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conString"]);


C#
SqlDataAdapter da = new SqlDataAdapter("select * from payout_transcation,payout_master", con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        grv.DataSource = ds;
        grv.DataBind();
 
Share this answer
 
Hi friend,

yes you have to join to table(that you want to saw on grid) and then bind them to data grid view.
 
Share this answer
 
Comments
fjdiewornncalwe 23-Feb-13 11:30am    
My 1. Repost of Solution 1

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