Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ItemCommand event not firing in Repeater

Status
Not open for further replies.

TeaAddictedGeek

Programmer
Apr 23, 1999
271
US
Here's what I have:

I am attempting to toggle back and forth between two image buttons as far as their visibility is concerned. Each should be firing an event within a Repeater to toggle one to visible and the other to not:

<asp:ImageButton
runat="server"
ID="btnCollapse"
CommandName="Collapse"
ImageUrl="images/Collapse.gif"
Visible = "true"/>
<asp:ImageButton
runat="server"
ID="btnExpand"
CommandName="Expand"
ImageUrl="images/Expand.gif"
Visible="false" />

Here's the C# code:

protected void rtASAP_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "Collapse")
{
((ImageButton)this.rtASAP.FindControl("btnCollapse")).Visible = false;
((ImageButton)this.rtASAP.FindControl("btnExpand")).Visible = true;
}
else
{
if (e.CommandName == "Expand")
{
((ImageButton)this.rtASAP.FindControl("btnCollapse")).Visible = true;
((ImageButton)this.rtASAP.FindControl("btnExpand")).Visible = false;
}
}

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.rtASAP.ItemDataBound += new RepeaterItemEventHandler(this.rtASAP_ItemDataBound);
this.rtASAP.ItemCommand += new RepeaterCommandEventHandler(this.rtASAP_ItemCommand);
this.Load += new System.EventHandler(this.Page_Load);

}


So far it is completely ignoring the ItemCommand event and I've tried putting a breakpoint in there to see if it is accessing ANY code--no dice.

Any ideas on what's wrong here?


Thanks in advance!

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs."
-Joseph Weizenbaum
 
Ok I got it to work and it's choking on the image button calls. How do I access the ImageButtons in there?

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs."
-Joseph Weizenbaum
 
Got this solved too--never mind!

I decided to eliminate a button and get the toggle going for the image URL. Worked much better.

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs."
-Joseph Weizenbaum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top