Problems with button in a repeater

P

pnr

I have an repeater that contains data witch it schould be possible to
delete, I have placed a delete button in each row, but i can't make
it work :-(

This is my repeater (just a little bit of it):

<asp:repeater id="Repeater1" runat="server"
OnItemCommand="testKnap_Click">

<ItemTemplate>

<asp:Button Text=<%# DataBinder.Eval(Container.DataItem,
"nyhedsNr") %> runat=server
ID="testKnap"></asp:Button>

</ItemTemplate>


and the cs file:

private void InitializeComponent()
{
this.Repeater1.ItemCommand += new
System.Web.UI.WebControls.RepeaterCommandEventHandler(this.testKnap_Click);
this.Load += new System.EventHandler(this.Page_Load);

}

protected void testKnap_Click(object source,
System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
Response.Write("HERE" + e.CommandName.ToString());

}


It submits when i hit the button, but it dosen't write the text from
Response.Write..

Any one that can help me make it work?
 
N

Natty Gur

Hi,

1) I run your code on my machine and it works.
2) You attached the event twice (by adding to delegate (page_init) and
using attribute (HTML)) so actually the repeater event will be call
twice. You should use one of those options.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
P

pnr

I have tried everything, but i can't make it work. Do you have an
idear too what could be wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top