user203687
user203687

Reputation: 7237

Repeater does not fire ItemCommand event

I searched the web on this topic and got plenty of suggestions from every one (including other stackoverflow threads).

Finally, I thought implement as shown exactly here.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.onitemcommand(VS.71).aspx

Still frustrated.

My repeater is available in a user control and I added the user control as a web part to an existing webpartzone. I could see all rows in the repeater (along with buttons). Once I click the (any) button, it loses all the rows and itemcommand never fires.

I am using ASP.NET 4.0

Can anyone help me on this.

Upvotes: 0

Views: 2861

Answers (2)

Niranjani
Niranjani

Reputation: 11

All the time, the Repeater has to be bound. Otherwise, Repeater_ItemCommand EVENT of the Repeater won't be fired.

That means:

     if (!IsPostBack)
            {
               BindRepeater();
            }
            else
            {
                BindRepeater();

            }

Upvotes: -1

Keith
Keith

Reputation: 5381

Databound list controls (just like any other dynamically-created controls) need to be recreated on postback. Do you have your Databind call within an if (!IsPostback) {} ?

Source code might help determine your specific issue.

Upvotes: 2

Related Questions