Click here to Skip to main content
15,886,632 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
Hi,

I was wondering how i could make a ASP website where the label, image and textbox is made dynamic and keeps adding controles as much as many rows there are in the SQL database.

So if i add a row in the sql database and i open the web application that row would automatically show it self.

I know how to make controles dynamic but i don't know how to add teh SQL connection to it.

I hope i explained my self enough and hope that you guys can help me.

Many thanks,

Robert
Posted
Comments
F-ES Sitecore 7-Sep-15 4:58am    
Buy a book on asp.net (either MVC or webforms) and go through it, or at least go through on-line tutorials for asp.net. Concepts such as getting data from SQL and showing it on a page will be covered.
Zephyrlord92 7-Sep-15 5:16am    
Hi thank you for your reply. i know how to connect a asp to a sql database but what i asked is how to connect the controles which are dynamically made to a database.
F-ES Sitecore 7-Sep-15 5:24am    
It makes no difference where the controls have come from, you populate them in the same way.

1 solution

You would need to loop over each row returned in code and create controls dynamically for each piece of data that you want to associate with them. Then write those controls out to the page.

You would add the data to display something like:

textbox.text = data_item_from_db.value;

Then, perhaps a PlaceHolder and:

placeholder.controls.add(textbox);

That's very simplistic but should enable you to figure it out.
 
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