crazyboybert
Programmer
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.
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
------------------------------------
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="rptPendingOrders" runat="server">
<headertemplate><hr /></headertemplate>
<separatortemplate><hr /></separatortemplate>
<itemtemplate>
<table>
...edited code...
<tr><td colspan="2" style="text-align:right"><asp:button runat="server" commandname="shipped" text="Order Shipped" cssclass="button"></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
------------------------------------