473,394 Members | 2,090 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,394 software developers and data experts.

Events with repeater items

I have a repeater that will have linkbuttons. I have googled much but
cannot find a solution to the following.

Since the items are dynamic I need to be able to attach handlers to the
linkbuttons to handle when they are clicked within server code. I can find
no examples of this.

Any examples?

Thanks
Lloyd Sheen

Jun 23 '07 #1
2 1682
On Jun 23, 9:52 pm, "Lloyd Sheen" <a...@b.cwrote:
I have a repeater that will have linkbuttons. I have googled much but
cannot find a solution to the following.

Since the items are dynamic I need to be able to attach handlers to the
linkbuttons to handle when they are clicked within server code. I can find
no examples of this.

Any examples?

Thanks
Lloyd Sheen
Hi...

1. Add Link Button in ItemTemplate of reapeater
2. then add a commad name in the link attribute,.,,,
3. Subscribe the ItemDataBound to customize the items more
4. Subscribe the ItemCommand and then do code for link button
clicked...

<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<!--More data bound code will go here-->
<asp:LinkButton ID="lnkSelect" Text="Select"
CommandName="Select" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
protected void Repeater1_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.Item)
{
LinkButton btn = e.Item.FindControl("lnkSelect") as
LinkButton;
}
}

protected void Repeater1_ItemCommand(object source,
RepeaterCommandEventArgs e)
{
if (e.CommandName == "Select")
{
//do code
}
}

Thanks
Masudur
http://munnacs.110mb.com


Jun 23 '07 #2

"Masudur" <mu*****@gmail.comwrote in message
news:11*********************@n60g2000hse.googlegro ups.com...
On Jun 23, 9:52 pm, "Lloyd Sheen" <a...@b.cwrote:
>I have a repeater that will have linkbuttons. I have googled much but
cannot find a solution to the following.

Since the items are dynamic I need to be able to attach handlers to the
linkbuttons to handle when they are clicked within server code. I can
find
no examples of this.

Any examples?

Thanks
Lloyd Sheen

Hi...

1. Add Link Button in ItemTemplate of reapeater
2. then add a commad name in the link attribute,.,,,
3. Subscribe the ItemDataBound to customize the items more
4. Subscribe the ItemCommand and then do code for link button
clicked...

<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<!--More data bound code will go here-->
<asp:LinkButton ID="lnkSelect" Text="Select"
CommandName="Select" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
protected void Repeater1_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.Item)
{
LinkButton btn = e.Item.FindControl("lnkSelect") as
LinkButton;
}
}

protected void Repeater1_ItemCommand(object source,
RepeaterCommandEventArgs e)
{
if (e.CommandName == "Select")
{
//do code
}
}

Thanks
Masudur
http://munnacs.110mb.com

Thanks, exactly what I needed.

LS

Jun 23 '07 #3

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

Similar topics

0
by: kamaumalone | last post by:
I have a dropdownlist which lives inside of a repeater. The repeater accepts user input via textboxes and the aforementioned dropdownlist. The repeater accepts phone numbers and allows for an...
1
by: Mark Fox | last post by:
Hello, I have a repeater and in each itemtemplate I have a radiobuttonlist. I am attempting to figure out how on postback I could iterate through the rows displayed by the repeater and for...
1
by: Fraggle | last post by:
I have a repeater with controls added at run time. the <template> also contains a <asp:textbox that is made visible on some repeater elements. when I come to read the text info out it has...
2
by: Mark | last post by:
I am trying to use a Pagable Repeater with checkboxes in ASP.Net, I cannot seem to associate the checkbox with a particular database record so I lose the checked state from page-to-page. Below is...
3
by: Guoqi Zheng | last post by:
Sir, According to our design, very often, I need to have a different html code for the last row of our repeater control. I can not put those code difference into footer because those code has to...
7
by: charliewest | last post by:
Hello - I'm using a Repeater control to render information in a very customized grid-like table. The Repeater control is binded to a DataSet with several records of information. Within the...
2
by: Ceema M via DotNetMonster.com | last post by:
Hello all, I have a nested repeater, which displays categories(parent repeater) and corresponding subcategories(child repeater). Both repeaters have checkboxes. When I check category checkbox...
4
by: =?Utf-8?B?SmFtZXMgR2V1cnRz?= | last post by:
On my page, I have one repeater that contains a literal control and a nested repeater. The nested repeater contains a literal control. Both repeaters are databound with only one object (string). ...
1
by: champ.supernova | last post by:
Hi, I have a dropdownlist which is repeated inside a repeater. What I'm wanting is for when one instance of the dropdownlist has its selection changed, for 1) this to trigger an...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.