Hey guys. how do i create a loop so i can create a number of asp linkbutton?

            for (i = 0; i < filenames.Length; i++)

i have a loop the i want to generate linkbutton on my website, but i want it inside a table?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John ClaesSenior .Net Consultant & Technical AnalistCommented:
You can generate it using a repeater.

A repeater will create it's inside for every Element you give it

what do you need to do?

Html side

set everything you want to repeat for every File inside the <asp:repeater> tag
In your example you must add the LinkButton

Code side
Create the OnDataBound method for the repeater
for the given e.Item as filename you set the linkbutton with the data.
(know the first time you come accros the e.item can be null just leave the method

In the onLoad you can set your list of filenames as DataSet for the repeater and call the DataBound method.

What will happen?

The list is databound to the repeater and the repeater is called to be DataBound.
On that moment the Code will send every item one by one through the onDataBound method
there you'll set the inner Linkbox

hope to be clear and helpfull.
JCWEBHOSTAuthor Commented:
do you have some code please so i can follow?
John ClaesSenior .Net Consultant & Technical AnalistCommented:
I'll give you some Urls

Gives a simple example of using the repeater with auto binding

using the repeater with ItemDataBound method

uisng the repeater without ItemDataBoudn method but using Server-Side coding within the Html

hope to have helped
Poor beggar
Pratima PharandeCommented:
See this for simple solution in Table

Add one Panel control in Aspx page like this
                  <asp:Panel id="Panel1"  runat="server">Panel</asp:Panel>

then in code behind linkbuttons like this

      Table table = new Table();
                  for (int i=0; i<10; i++)
                              LinkButton lbt = new LinkButton();
                        TableCell cell = new TableCell();
                        TableRow row = new TableRow();
                        lbt.Text = i.ToString();


                  Panel1.Visible = true;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JCWEBHOSTAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.