Wiring up an ImageButton event in a repeater controls headertemplate tag

Discussion in 'ASP .Net Web Controls' started by Ryan Taylor, Jan 13, 2005.

  1. Ryan Taylor

    Ryan Taylor Guest

    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>
     
    Ryan Taylor, Jan 13, 2005
    #1
    1. Advertising

  2. Ryan Taylor

    Ryan Taylor Guest

    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?
     
    Ryan Taylor, Jan 13, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oisin Grehan
    Replies:
    3
    Views:
    524
    Natty Gur
    Jul 15, 2003
  2. Mick
    Replies:
    2
    Views:
    2,106
  3. =?Utf-8?B?SG9tYW0=?=

    Dynamic controls and event wiring

    =?Utf-8?B?SG9tYW0=?=, Feb 16, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    382
    =?Utf-8?B?SG9tYW0=?=
    Feb 16, 2005
  4. shruds
    Replies:
    1
    Views:
    946
    John C. Bollinger
    Jan 27, 2006
  5. Stephen Miller

    ImageButton in column's HeaderTemplate doesn't generate Click event

    Stephen Miller, Feb 15, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    162
Loading...

Share This Page