How to make dynamic links?

  • Thread starter Thread starter Peter K
  • Start date Start date
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
 
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()
 
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.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*********************************************
Think outside the box!
*********************************************
 
Back
Top