473,327 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How to create LinkButton in Repeater control from DataSet?

I want to read information out of a database at runtime (names of files available to download) and create a list of linkbuttons that the user can click on to download the file(s).

How can I accomplish this.

I've got this far:

In the html:

....
table>
<asp:Repeater ID="softwareList" Runat="server">
<ItemTemplate>
<tr>
<td>
<asp:LinkButton Runat="server">
<%# DataBinder.Eval(Container.DataItem,"SoftwarePath") %>
</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>

In the codebehind page:

private void Page_Load(object sender, System.EventArgs e)
{
if ( !Page.IsPostBack )
{
sqlDataAdapter1.Fill(dataSet11);
softwareList.DataSource = dataSet11;
softwareList.DataBind();
}
}

This reads the information out of the database and displays the items as links, but how do I "bind" the links to be able to download the file.
For example,

say my list looks like:

your_software_one.exe
more_software.exe

what more do I need to do to create the "click" event for each of these links to pass the filepath information to the download routine?
Nov 23 '05 #1
2 10739
You should add an OnCommand event handler tot he LinkButtons. In that event
handler you'll need to know which thing to download, so I'd suggest also
supplying a CommandName='<%# 'DataBinder.Eval(COntainer.DataItem, "SomeIDForYourDownload")%>'
then in your event handler simply check the COmmandName to know what to send
back via Response.BinaryWrite().

-Brock
DevelopMentor
http://staff.develop.com/ballen
I want to read information out of a database at runtime (names of
files available to download) and create a list of linkbuttons that the
user can click on to download the file(s).

How can I accomplish this.

I've got this far:

In the html:

...

<asp:Repeater ID="softwareList" Runat="server">
<ItemTemplate>
<tr>
<td>
<asp:LinkButton Runat="server">
<%# DataBinder.Eval(Container.DataItem,"SoftwarePath") %>
</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
In the codebehind page:

private void Page Load(object sender, System.EventArgs e)
{
if ( !Page.IsPostBack )
{
sqlDataAdapter1.Fill(dataSet11);
softwareList.DataSource = dataSet11;
softwareList.DataBind();
}
}
This reads the information out of the database and displays the items
as
links, but how do I "bind" the links to be able to download the file.
For example,
say my list looks like:

your software one.exe
more software.exe
what more do I need to do to create the "click" event for each of
these links to pass the filepath information to the download routine?

Nov 23 '05 #2
Brock,
Thaks for the reply - where/how do I add the OnCommand event handler - on
the codebehind page?
A quick snippet would be helpful - thanks!
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:b8**************************@msnews.microsoft .com...
You should add an OnCommand event handler tot he LinkButtons. In that
event handler you'll need to know which thing to download, so I'd suggest
also supplying a CommandName='<%# 'DataBinder.Eval(COntainer.DataItem,
"SomeIDForYourDownload")%>' then in your event handler simply check the
COmmandName to know what to send back via Response.BinaryWrite().

-Brock
DevelopMentor
http://staff.develop.com/ballen
I want to read information out of a database at runtime (names of
files available to download) and create a list of linkbuttons that the
user can click on to download the file(s).

How can I accomplish this.

I've got this far:

In the html:

...

<asp:Repeater ID="softwareList" Runat="server">
<ItemTemplate>
<tr>
<td>
<asp:LinkButton Runat="server">
<%# DataBinder.Eval(Container.DataItem,"SoftwarePath") %>
</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
In the codebehind page:

private void Page Load(object sender, System.EventArgs e)
{
if ( !Page.IsPostBack )
{
sqlDataAdapter1.Fill(dataSet11);
softwareList.DataSource = dataSet11;
softwareList.DataBind();
}
}
This reads the information out of the database and displays the items
as
links, but how do I "bind" the links to be able to download the file.
For example,
say my list looks like:

your software one.exe
more software.exe
what more do I need to do to create the "click" event for each of
these links to pass the filepath information to the download routine?


Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stan | last post by:
I cannot make the link buttons fire ItemCommand from repeater control. Here is the code: <asp:repeater id=rptLetters runat="server"> <itemtemplate> <asp:linkbutton id="lnkLetter"...
1
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
1
by: Jon S via DotNetMonster.com | last post by:
Hi all In short, I have a dataset that contains 10 records and the relevant headings. All I want to do is bind this dataset to a asp.net repeater control. All the examples I've seen create...
0
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
0
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation...
5
by: =?Utf-8?B?Um9iZXJ0IFNtaXRo?= | last post by:
Hi, I wish to create a repeater control in c#.net that allows for the selection of rows, any idea how this can be done. Regards Robert
2
by: =?Utf-8?B?Um9iZXJ0IFNtaXRo?= | last post by:
Hi I have a repeater control as shown below. The Itemtemplate contains a table with linkbuttons in each column of the row. However I wish to change the stlyle of the link button to...
5
by: Peter Larsen [CPH] | last post by:
Hi, The following sample shows a LinkButton in the HeaderTemplate of a Repeater control. The problem is that i'm not able to access the linkbutton in code (in the cs file) as long as the...
4
by: JFKJr | last post by:
Hello Guys, I have been trying to solve the following problem from past 3 days with no luck. This is what I am trying to do: I want to allow user (Professor) to choose a course material...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.