Wiring up an ImageButton event in a repeater controls headertemplate tag

R

Ryan Taylor

Hello.

I have a repeater control for listing some items out. I have in my header
template an ImageButton control. How can I wire that onclick event of the
ImageButton control. I only have the one button because I will be performing
a batch delete on items that have been checked by the user.

I have looked everywhere, but all the examples show wiring events for
multiple buttons in the ItemCommand of the repeater control. Must I still do
this, would it even work for a single button in the header?

The header code follows.

<headertemplate>
<table width="100%" border="0" cellspacing="1" cellpadding="3"
class="list">
<tr class="list_title">
<td width="20" align="center"><a href="News.aspx?callname=new"><img
src="images/icons/icon_record_new.gif" width="19" height="20" alt="New
Record" border="0"></a></td>
<td colspan="2" width="100%">News List</td>
<td width="20" align="center"><asp:imagebutton id="btnDelete"
imageurl="images/icons/icon_trash.gif" width="19" height="20"
runat="server"></asp:ImageButton></td>
</tr>
<tr bgcolor="FFFFFF">
<td colspan="5"></td>
</tr>
<tr class="list_subtitle">
<td align="center"></td>
<td>&nbsp;Date</td>
<td width="1%">&nbsp;Enabled&nbsp;</td>
<td align="center"></td>
</tr>
<tr bgcolor="FFFFFF">
<td colspan="5"></td>
</tr>
</HeaderTemplate>
 
R

Ryan Taylor

Ok, I've got it working.

I created the function

protected void btnDelete_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
int n = rptrNews.Items.Count;
}

and added in OnClick="btnDelete_Click" to the attributes of the image button
in the aspx page.

But is this the best way?
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top