472,780 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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:linkbutton id="lnkLetter"
runat="server" commandname="Filter"
CommandArgument='<%#
DataBinder.Eval(Container, "DataItem.Letter")%>'>
<%# DataBinder.Eval
(Container, "DataItem.Letter")%>
</asp:linkbutton>
</itemtemplate>
</asp:repeater>

In code-behind I've got:

this.rptLetters.ItemCommand += new
System.Web.UI.WebControls.RepeaterCommandEventHand ler
(this.OnLetterClicked);

and

protected void OnLetterClicked(object source,
System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
if (e.CommandName == "Filter")
{
letterFilter = (string)
e.CommandArgument;
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="Filter"
CommandArgument='<%#
DataBinder.Eval(Container, "DataItem.Letter")%>'
Text='<%# DataBinder.Eval
(Container, "DataItem.Letter")%>' />
</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 11922
Hi Stan,

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

DataList.ItemCommand Event
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwebuiwebcontrolsdatalistclassitemcomman dtopic.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:LinkButton id="SelectButton"
Text="Select"
CommandName="Select"
runat="server"/>

Item <%# DataBinder.Eval(Container.DataItem, "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.com> 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:linkbutton id="lnkLetter"
runat="server" commandname="Filter"
CommandArgument='<%#
DataBinder.Eval(Container, "DataItem.Letter")%>'>
<%# DataBinder.Eval
(Container, "DataItem.Letter")%>
</asp:linkbutton>
</itemtemplate>
</asp:repeater>

In code-behind I've got:

this.rptLetters.ItemCommand += new
System.Web.UI.WebControls.RepeaterCommandEventHand ler
(this.OnLetterClicked);

and

protected void OnLetterClicked(object source,
System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
if (e.CommandName == "Filter")
{
letterFilter = (string)
e.CommandArgument;
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="Filter"
CommandArgument='<%#
DataBinder.Eval(Container, "DataItem.Letter")%>'
Text='<%# DataBinder.Eval
(Container, "DataItem.Letter")%>' />
</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
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...
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: 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...
0
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...
3
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...
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: 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...
7
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...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.