473,657 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Link buttons don't fire ItemCommand in repeater control, is this a bug?

I cannot make the link buttons fire ItemCommand from
repeater control.

Here is the code:

<asp:repeater id=rptLetters runat="server">
<itemtemplate >
<asp:linkbutt on id="lnkLetter"
runat="server" commandname="Fi lter"
CommandArgument ='<%#
DataBinder.Eval (Container, "DataItem.Lette r")%>'>
<%# DataBinder.Eval
(Container, "DataItem.Lette r")%>
</asp:linkbutton>
</itemtemplate>
</asp:repeater>

In code-behind I've got:

this.rptLetters .ItemCommand += new
System.Web.UI.W ebControls.Repe aterCommandEven tHandler
(this.OnLetterC licked);

and

protected void OnLetterClicked (object source,
System.Web.UI.W ebControls.Repe aterCommandEven tArgs e)
{
if (e.CommandName == "Filter")
{
letterFilter = (string)
e.CommandArgume nt;
PopulateGrid();
}
}

and it is does not fire the click event!
However, if I replace link button with regular buttons

<asp:repeater id=rptLetters runat="server">
<itemtemplate >
<asp:button id="lnkLetter" runat="server"
commandname="Fi lter"
CommandArgument ='<%#
DataBinder.Eval (Container, "DataItem.Lette r")%>'
Text='<%# DataBinder.Eval
(Container, "DataItem.Lette r")%>' />
</itemtemplate>
</asp:repeater>

exactly the the same code works fine.

I am using 1.0.3705 framework.

Is this a bug?

Thanks,

-Stan

Nov 18 '05 #1
2 12005
Hi Stan,

Based on my research and experience, the following information is useful to
you. Please refer to it carefully.

DataList.ItemCo mmand Event
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwebu iwebcontrolsdat alistclassitemc ommandtopic.asp
"...
The ItemCommand event is raised when any button is clicked in the DataList
control and is commonly used when you have a button control with a custom
CommandName value.
...
The following example demonstrates how to specify and code a handler for
the ItemCommand event to select an item from the DataList control.
...
<ItemTemplate >

<asp:LinkButt on id="SelectButto n"
Text="Select"
CommandName="Se lect"
runat="server"/>

Item <%# DataBinder.Eval (Container.Data Item, "Item") %>

</ItemTemplate>
..."

If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #2
Since this is in a data repeater the code fires the ItemCommand for the data
repeater instead of the LinkButton. This sounds strange but really works
out becuase sometime you can get away without sending any parameters, if the
data you need is in on DataRepeater Item.

To see if this is happening create an event handler for the Repeater control
and put a Messagebox.Show as the only line of code. The everytime you click
the link the message should popup. You can even sent a breakpoint on the
MessageBox.Show and view what data you can access from the datarepeater
using the e.Item object. I have used this numerous times, but the first
time it was very frustrating learning how to extract data from the
datarepeater. Feel free to send me any more questions you might have.

S. Shawn Mehaffie
PC************@ hotmail.com


"Stan" <no****@yahoo.c om> wrote in message
news:b4******** *************** *****@phx.gbl.. .
I cannot make the link buttons fire ItemCommand from
repeater control.

Here is the code:

<asp:repeater id=rptLetters runat="server">
<itemtemplate >
<asp:linkbutt on id="lnkLetter"
runat="server" commandname="Fi lter"
CommandArgument ='<%#
DataBinder.Eval (Container, "DataItem.Lette r")%>'>
<%# DataBinder.Eval
(Container, "DataItem.Lette r")%>
</asp:linkbutton>
</itemtemplate>
</asp:repeater>

In code-behind I've got:

this.rptLetters .ItemCommand += new
System.Web.UI.W ebControls.Repe aterCommandEven tHandler
(this.OnLetterC licked);

and

protected void OnLetterClicked (object source,
System.Web.UI.W ebControls.Repe aterCommandEven tArgs e)
{
if (e.CommandName == "Filter")
{
letterFilter = (string)
e.CommandArgume nt;
PopulateGrid();
}
}

and it is does not fire the click event!
However, if I replace link button with regular buttons

<asp:repeater id=rptLetters runat="server">
<itemtemplate >
<asp:button id="lnkLetter" runat="server"
commandname="Fi lter"
CommandArgument ='<%#
DataBinder.Eval (Container, "DataItem.Lette r")%>'
Text='<%# DataBinder.Eval
(Container, "DataItem.Lette r")%>' />
</itemtemplate>
</asp:repeater>

exactly the the same code works fine.

I am using 1.0.3705 framework.

Is this a bug?

Thanks,

-Stan

Nov 18 '05 #3

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

Similar topics

2
3186
by: Jorge Ayala | last post by:
Well I'm trying to catch and act upon a button event that is placed within the item template of a repeater control. Yet the code I'm using isn't working. What I've seen out there to explain how to do this is way complicated and assumes a familiarity with dot net that I don't have yet. I'll get it eventually but this is where I'll get it. Here's my code. First part is the user control and second is the code behind page Use control
1
5428
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:
1
6414
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...
1
1839
by: Imran Aziz | last post by:
Hello All, I have an asp:linkbutton in a repeater control, what I want to do is when someone clicks the link button I should get a value for the link button, and accordingly do some action. How can I do that, can someone please help me with that. Imran.
0
1113
by: riddion | last post by:
Hello. I am having problems with the repeater webform control. Inside the <ItemTemplate> section I have a Calendar control. This is for so the user can choose a different date on each of the items in the repeater. I also have buttons in the <ItemTemplate> section. The buttons' click event is catched by the repeater's ItemCommand event and they are handled, but Calendar's SelectionChanged event is not catched by the ItemCommand event. I...
3
8519
by: Mark | last post by:
Assume you want to dynamically add one to many link button controls to a web page dynamically at run time. Each link button needs to post back and execute code. As the link buttons are created at run time and the number may vary, we can't statically tie to the event to a control. I'm assuming I need to dynamically add event handlers at run time, and that one method could act as the event handler, with unique event args being created for...
0
2558
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
6755
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created link buttons to stay wired up to their click events. I have what is basically a simply survey question generation page. The page first displays a few static fields and a dropdownlist of various options for the user to select. When the user...
7
3758
by: gnewsgroup | last post by:
OK, I am still trying to achieve something like what is shown in the following PNG image. http://farm3.static.flickr.com/2066/1808692173_ea202973a3_o.png I thought about doing this with a plain Table server control, but the problem is that this control does not provide enough events for us to identify the row in which the button is clicked. See a discussion I initiated in the following thread:
0
8384
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
8302
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,...
1
8499
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
8601
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
7314
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
6162
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...
0
5630
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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.