RSS Forums RSS
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting

dynamic tables

Join Date: Sep 2005
Posts: 7
Reputation: sandy2005 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sandy2005 sandy2005 is offline Offline
Newbie Poster

Re: dynamic tables

  #5  
Sep 12th, 2005
Hi

I need to render a table with dynamic rows based on data obtained through data reader. Each row has a image link button, a link button
and a label to which data comes from the database. In the earlier message you said we can use either a datalist, repeator or datagrid.
Can you please let me know how to render the table dynamically.

Thanks
Sandy

Originally Posted by tgreer
What does the rendered table need to do?

If the answer is "it needs to contain "stuff" that the user will click/change, and then more server code will run", then you need to "Render dynamic controls", and should use a server side control to do that. Repeater. DataList. DataGrid.

If the answer is "sit there and look pretty", then you simply output a good old fashioned HTML Table, by using the LiteralControl.

The idea is: drag a PlaceHolder where you want the table to be.

Build a query, run the query, return a SqlDataReader.

Start your table:

PlaceHolder1.Controls.Add(new LiteralControl("<table>"));

Read through your datareader, outputting tags and content as you go:

[PHP]while(myDataReader.Read())
{
PlaceHolder1.Controls.Add(new LiteralControl("<tr><td>" + myDataReader["myField"].ToString() + "</td></tr>"));
}[/PHP]

And so on.
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:20 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC