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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

repeater item command

Status
Not open for further replies.

crazyboybert

Programmer
Jun 27, 2001
798
GB
Hi All

I'm having trouble with getting a button inside a repeater control to fire the ItemCommand event. The code for the page is below edited for clarity.
Code:
Web form

<asp:repeater id=&quot;rptPendingOrders&quot; runat=&quot;server&quot;>
<headertemplate><hr /></headertemplate>
<separatortemplate><hr /></separatortemplate>
<itemtemplate>
<table>
...edited code...
<tr><td colspan=&quot;2&quot; style=&quot;text-align:right&quot;><asp:button runat=&quot;server&quot; commandname=&quot;shipped&quot; text=&quot;Order  Shipped&quot; cssclass=&quot;button&quot;></asp:button></td></tr>
</table>
</itemtemplate>
<footertemplate><hr /></footertemplate>
</asp:repeater>

Code Behind (C#)

protected System.Web.UI.WebControls.Repeater rptPendingOrders;

private void InitializeComponent(){    
	this.Load += new System.EventHandler(this.Page_Load);
	this.rptPendingOrders.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(this.rptPendingOrders_ItemBound);
	this.rptPendingOrders.ItemCommand += new System.Web.UI.WebControls.RepeaterCommandEventHandler(this.rptPendingOrders_ItemCommand);
}


private void rptPendingOrders_ItemCommand(object sender, System.Web.UI.WebControls.RepeaterCommandEventArgs e){
	Response.Write(e.CommandName.ToString()); Response.End();
}

When the button is clicked the page submits and refreshes but the code inside the itemcommand event handler doesnt seem to run. I dont get any error at all but nothing happens. I've tried specifying the handler in the repeater tag in aspx, making the text property of the button the result of a databinding in case that would wire it up but to no avail.

The repeater does contain a nested datagrid and both are databound from a single dataset using a parent-child data relation between the tables. I don't expect this to be the cause but havent checked yet.

Anybody got any ideas?

Rob

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
Thanks stsuing I was looking for exactly that article last night at home after remembering reading it on MSDN a while back. Doesnt help with my problem though. Is a bit high level and doesnt get dirty with ItemCommnd events etc.

There are plenty of examples online of code using the ItemCommand event for a button in a repeater with supposed success - there is even one in the .NET Framework Reference but for the life of me I can't it to work.

Any help still greatly appreciated...

Cheers Rob

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top