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
"Stan" <> wrote in message
news:b43901c3b8f1$c6300210$...
> 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
>