How to make dynamic links?

P

Peter K

Hi

I need to make a list of "download file links" on a webpage. All the data
is dynamic - it depends on the user's actions how many files, and which
files, I need to present in the list. The files are identified by an id in
a database.

How do I do this? I was thinking I could somehow make a list of <a href...>
tags which could call a method in my c# code-behind. Is this possible? Or
is there a better way?

The links need to pass a "file id" to my code-behind so I can find the
correct file in a database and supply the file to the user (I assume I use
the Response stream to send the file).

Thanks,
Peter
 
G

Guest

Hi

I need to make a list of "download file links" on a webpage. All the data
is dynamic - it depends on the user's actions how many files, and which
files, I need to present in the list. The files are identified by an id in
a database.

How do I do this? I was thinking I could somehow make a list of <a href...>
tags which could call a method in my c# code-behind. Is this possible? Or
is there a better way?

The links need to pass a "file id" to my code-behind so I can find the
correct file in a database and supply the file to the user (I assume I use
the Response stream to send the file).

Thanks,
Peter

there are a lot of ways to do it

as an example (using a DataList Control)

<asp:DataList id="UrlList" runat="server">
<ItemTemplate>
<a href='mypage.aspx?id=<%# DataBinder.Eval(Container.DataItem,
"StringValue") %>'>Click here</a>
</ItemTemplate>
</asp:DataList>

in the code-behind:

UrlList.DataSource = CreateDataSourceOfURLs()
UrlList.DataBind()
 
C

Cowboy \(Gregory A. Beamer\)

It sounds like you are storing the file information in some form of data
store (database, XML file, search of file system that can be stored in
objects or files). If so, get the information into a DataSet or object
collection that can be bound. As far as how to do the links themselves, a
Repeater is a very good choice, with a Hyperlink in the item template.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top