473,545 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="softwareLis t" Runat="server">
<ItemTemplate >
<tr>
<td>
<asp:LinkButt on Runat="server">
<%# DataBinder.Eval (Container.Data Item,"SoftwareP ath") %>
</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>

In the codebehind page:

private void Page_Load(objec t sender, System.EventArg s e)
{
if ( !Page.IsPostBac k )
{
sqlDataAdapter1 .Fill(dataSet11 );
softwareList.Da taSource = dataSet11;
softwareList.Da taBind();
}
}

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_o ne.exe
more_software.e xe

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 10772
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.Eva l(COntainer.Dat aItem, "SomeIDForYourD ownload")%>'
then in your event handler simply check the COmmandName to know what to send
back via Response.Binary Write().

-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="softwareLis t" Runat="server">
<ItemTemplate >
<tr>
<td>
<asp:LinkButt on Runat="server">
<%# DataBinder.Eval (Container.Data Item,"SoftwareP ath") %>
</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
In the codebehind page:

private void Page Load(object sender, System.EventArg s e)
{
if ( !Page.IsPostBac k )
{
sqlDataAdapter1 .Fill(dataSet11 );
softwareList.Da taSource = dataSet11;
softwareList.Da taBind();
}
}
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****@NOSPAMd evelop.com> wrote in message
news:b8******** *************** ***@msnews.micr osoft.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.Eva l(COntainer.Dat aItem,
"SomeIDForYourD ownload")%>' then in your event handler simply check the
COmmandName to know what to send back via Response.Binary Write().

-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="softwareLis t" Runat="server">
<ItemTemplate >
<tr>
<td>
<asp:LinkButt on Runat="server">
<%# DataBinder.Eval (Container.Data Item,"SoftwareP ath") %>
</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
In the codebehind page:

private void Page Load(object sender, System.EventArg s e)
{
if ( !Page.IsPostBac k )
{
sqlDataAdapter1 .Fill(dataSet11 );
softwareList.Da taSource = dataSet11;
softwareList.Da taBind();
}
}
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
11991
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" runat="server" commandname="Filter" CommandArgument='<%#
1
5413
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 fragment of a very simple page that I wrote that will drill down into the displayed item. The result is to be display on the same page so that the...
1
6397
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 binding it to a repeater control. This repeater control has multiple text boxes and buttons. Can you please tell me how can i do paging in this case ?...
1
1689
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 table cell headings and then map to them headings like: <%#DataBinder.Eval(Container.DataItem, "CompanyName")%>,...
0
2256
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 chkAll. I simply want to have chkAll be checked if every item in the repeater has its checkbox checked. In the code behind page, I can access the...
0
2541
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 link (1,2,3 so on). The code can be found in SubscriptionCart.aspx.cs. Default.aspx ------------
5
4099
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
2145
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 text-decoration:underline on mouseover and text-decoration:none on mouseout The link button does not have a mouseover attribute and it won't let me add on Any...
5
13902
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 linkbutton stays in the repeater control - see the following line: testLink.CommandArgument = "just testing"; or testLink.Text = "Some new text";
4
10795
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 using "asp:FileUpload" control, upload into the database by clicking "asp:Button" control and allow Professor to view the files he/she uploaded using...
0
7473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7408
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7661
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7433
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7763
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5340
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3458
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1891
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.