Link to home
Start Free TrialLog in
Avatar of JCWEBHOST
JCWEBHOST

asked on

linkbutton

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?

Avatar of John Claes
John Claes
Flag of Belgium image

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.
Avatar of JCWEBHOST
JCWEBHOST

ASKER

do you have some code please so i can follow?
I'll give you some Urls

Gives a simple example of using the repeater with auto binding
http://www.w3schools.com/ASPNET/aspnet_repeater.asp
http://blogs.sitepoint.com/asp-net-repeater-control/


using the repeater with ItemDataBound method
http://support.microsoft.com/kb/307860

uisng the repeater without ItemDataBoudn method but using Server-Side coding within the Html
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.itemdatabound.aspx

hope to have helped
Poor beggar
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks