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 <Link> tag and make it as a linkbutton and when user will click the button, it will open a pdf file named within the <pdf> 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?

Member Avatar for stbuchok

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);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.