473,791 Members | 3,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Asp repeater & LinkButton

Hi

are there any "gotchas" with using an asp:repeater that means that the
"onclick" method of a LinkButton created in the repaeter does not fire?

I at least cannot get it to work. I have a webpage where the user can enter
some search criteria (via dropdowns and textboxes) and then perform a search
and have results presented. The results list includes linkbuttons which the
user can click on to obtain more detailed results.

Here is some example code if anyone would be kind enough to offer advice.

On html/asp:

<asp:repeater id="ResultsRepe ater" onitemdatabound ="Item_DataBoun d"
Runat="server">
<HeaderTemplate >
<table>
<tr>
<th>Name</th>
<th>Code</th>
</tr>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td><%# ((DataRow)Conta iner.DataItem). Name %></td>
<td>
<asp:LinkButt on id="MyButton"
OnClick="MyButt onMenuItem_Clic k" Runat="server" text="<%#
((DataRow)Conta iner.DataItem). Code %>" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate >
</table>
</FooterTemplate>
</asp:repeater>
In code behind:

private void Page_Load(objec t sender, System.EventArg s e)
{
log.Info("Page_ Load");

string detail = Request.Params["detail"];

if (!IsPostBack)
{
log.Info("Page_ Load !IsPostBack");

// Populates fields for supplying search criteria:
PopulateSearchD ropDowns();
}
else
{
log.Info("Page_ Load IsPostBack");
}

log.Info("PortT oPort Page_Load END");
}

// Never gets called
public void MyButtonMenuIte m_Click(object sender, EventArgs e)
{
log.Info("MyBut tonMenuItem_Cli ck");
LinkButton btn = (LinkButton)sen der;

// Supposed to do stuff to handle the linkbutton click...
}

// Click-handler for the "send" button, which generates the data for the
repeater.
private void SendQueryButton _Click(object sender, System.EventArg s e)
{
log.Info("SendB utton_Click ...");

// ... data handing/validation... call the database "Search" method to
get the data:
ArrayList results = Search();
ResultsRepeater .DataSource = results;
ResultsRepeater .DataBind();

log.Info("END SendButton_Clic k ...");
}
Nov 17 '05 #1
2 3808
Hi,

No really, it should work fine.

What does Item_DataBound? the problem may lay there.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Peter Kirk" <pk@alpha-solutions.dk> wrote in message
news:Og******** *****@TK2MSFTNG P15.phx.gbl...
Hi

are there any "gotchas" with using an asp:repeater that means that the
"onclick" method of a LinkButton created in the repaeter does not fire?

I at least cannot get it to work. I have a webpage where the user can
enter some search criteria (via dropdowns and textboxes) and then perform
a search and have results presented. The results list includes linkbuttons
which the user can click on to obtain more detailed results.

Here is some example code if anyone would be kind enough to offer advice.

On html/asp:

<asp:repeater id="ResultsRepe ater" onitemdatabound ="Item_DataBoun d"
Runat="server">
<HeaderTemplate >
<table>
<tr>
<th>Name</th>
<th>Code</th>
</tr>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td><%# ((DataRow)Conta iner.DataItem). Name %></td>
<td>
<asp:LinkButt on id="MyButton"
OnClick="MyButt onMenuItem_Clic k" Runat="server" text="<%#
((DataRow)Conta iner.DataItem). Code %>" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate >
</table>
</FooterTemplate>
</asp:repeater>
In code behind:

private void Page_Load(objec t sender, System.EventArg s e)
{
log.Info("Page_ Load");

string detail = Request.Params["detail"];

if (!IsPostBack)
{
log.Info("Page_ Load !IsPostBack");

// Populates fields for supplying search criteria:
PopulateSearchD ropDowns();
}
else
{
log.Info("Page_ Load IsPostBack");
}

log.Info("PortT oPort Page_Load END");
}

// Never gets called
public void MyButtonMenuIte m_Click(object sender, EventArgs e)
{
log.Info("MyBut tonMenuItem_Cli ck");
LinkButton btn = (LinkButton)sen der;

// Supposed to do stuff to handle the linkbutton click...
}

// Click-handler for the "send" button, which generates the data for the
repeater.
private void SendQueryButton _Click(object sender, System.EventArg s e)
{
log.Info("SendB utton_Click ...");

// ... data handing/validation... call the database "Search" method to
get the data:
ArrayList results = Search();
ResultsRepeater .DataSource = results;
ResultsRepeater .DataBind();

log.Info("END SendButton_Clic k ...");
}

Nov 17 '05 #2
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > skrev
i en meddelelse news:OQ******** ******@tk2msftn gp13.phx.gbl...
Hi,

No really, it should work fine.

What does Item_DataBound? the problem may lay there.


Hi

thanks for the reply. After more experimentation it does seem that the code
works as I would have expected it to, if I run it as a "stand-alone"
webpage. Unfortunately the ascx I am making is running inside a "container"
(a CMS) which appears to swallow these click events. I will need to
investigate further.

Peter
Nov 17 '05 #3

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

Similar topics

3
2137
by: Mark | last post by:
I am looking for an example of using checkboxes in a repeater control where the checkbox state is persisted from page to page. Thank you, Mark
0
1797
by: Amir | last post by:
Hi every one This is the problem: I have a UserControl that contains a Repeater and a few LinkButton. The Repeater generate some linkButton. I use this control for implementing paging solution for another repeater in page. (So I have a repeater and a Usercontrol that contains repeater)
1
5448
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 user can keep on drilling down:
3
4169
by: Shimon Sim | last post by:
I put linkbutton in a repeater header. I attached event handler in makeup as onclick="btnSort_Click". Made btnSort_Click method public. It doesn't fire if I click on it. I tried to attach it in ItemDataBound event but I think it is too late. What am I doing wrong? Thanks Shimon.
1
6429
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 ? I'm posting my code below. The problem is that if i click on "AdjustThisAd" button, it opens...
3
7842
by: renil | last post by:
I have a repeater control that displays info. from a datatable. Each row in the repeater has a checkbox. Also, I have a delete linkbutton outside the repeater control. What I'm trying to do when the delete linkbutton is clicked is get the SubscriptionID from the repeater control for each row in which the checkbox is checked, then call a delete function. (See the code for the .aspx and .aspx.cs below.) The problem I'm having is that I...
0
2810
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 checked property of chkReconciled by doing the following: Dim CurrentCheckBox As CheckBox...
0
2285
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 checked property of chkReconciled by doing the following: Dim CurrentCheckBox As CheckBox...
5
13941
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";
0
9669
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9517
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9997
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9030
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4110
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
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.