dataset - table question

G

Guest

I have a dataset that has 8 tables in it, (table, table1, table2, table3,
....) how can i have each table populate a seperate datagrid on my one web
form without having to put 8 seperate datagrids on my page?

I want 1 grid but have each table populate a grid on my form.
 
S

Swanand Mokashi

G

Guest

no,,
here is what i have,
i have my dataset it has 8 tables in it
table0, table1, table2, table3

I want to have a seperate grid for each table so table0 is shown in one
grid, table1 in another, and so on, BUT I dont want to have 8 seperate grid
controls on my page, so is there a way to loop through them all and create a
new grid for each table in my dataset?
 
S

Swanand Mokashi

Sure --

Something like this :

You can put a placeholder control on the page (say called as placeHolder1

Now assuming your dataset name is Dataset1
Datagrid datagrid1;
foreach (DataTable dataTable in Dataset1.Tables)
{
datagrid1 = new Datagrid();
datagrid1.DataSource = dataTable;
datagrid1.DataBind();
placeHolder1.Controls.Add(datagrid1);
}

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top