hai
I want bind gridview , to all my database table name,
i having database name Authoriz and table name x,y,z......i want to bind all table names dynamically in run time,to my gridview.
iam using c#.net 2008,sql 2008 web application,
pls give c# coding urgent pls....
Binding database all tables to grid view
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Mayur GujrathiRank #666 · 3.6K reputationPosted May 7, 2011, 12:34 AM EDT
in dataset there can be more than one table so you can do this
i am not sure and also i havnt done this before
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
GridView1.DataSource = ds.Tables(1)
GridView1.DataBind()
GridView1.DataSource = ds.Tables(2)
GridView1.DataBind()
and make proper arrangement of columns using template fields or as per your need
Mayur GujrathiRank #666 · 3.6K reputationPosted May 7, 2011, 12:39 AM EDT
string sConn = "Data Source=(local);Network Library=DBMSSOCN;Initial Catalog=Northwind;User ID=sa;Password=stefan;";
string sSQL = "select * from table1;select * from table2";
DataSet ds = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(sConn,
CommandType.Text, sSQL);