954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to create n number of dynamic linkbuttons

I want to create n numbers of dynamic link buttons runtime.
I will have an xml file which has the format like

<category>
<link>
Link1
</link>
<pdf>
PDF1
</pdf>
</category>
<category>
<link>
Link2
</link>
<pdf>
PDF2
</pdf>
</category>
<category>
<link>
Link3
</link>
<pdf>
PDF3
</pdf>
</category>
........
........
........
and so on


I have to take the element within the tag and make it as a linkbutton and when user will click the button, it will open a pdf file named within the tag.
It may happen that the xml has 10 such tags, it may have 200 tags, based on the number of such tags, our link buttons will be created and pdf files will be opened on clicking the respective linkbuttons. How can I achieve this?

subhankar02dey
Light Poster
27 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

Loop through the items in the xml. For each of the categories, get the link and the pdf and make a link button.

Hope this helps (I don't have time to write the actual code)

//this is not the actual code.
foreach(...)
{
    LinkButton link = new LinkButton();

    link.URL = pdf;
    link.Text = link

    //panel should be any kind of server side control that you can add other controls to
    panel.child.add(link);
}
stbuchok
Master Poster
730 posts since May 2011
Reputation Points: 120
Solved Threads: 93
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: