Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP Repeater ItemDataBound : Getting ImageButton

Posted on 2010-08-16
3
Medium Priority
?
1,274 Views
Last Modified: 2012-05-10
I have the following repeater:


<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" OnItemDataBound="Repeater_ItemDataBound">
    <HeaderTemplate>
      <ul id="navbar">
    </HeaderTemplate>
    <ItemTemplate>
      <li><span>
          <asp:ImageButton ID="imgButton" ImageUrl='<%# Bind("Image") %>' runat="server" PostBackUrl='<%# Bind("Path") %>'
            AlternateText='<%# Bind("AltText") %>' CssClass='<%# Bind("Clicked") %>' /></span>
      </li>
    </ItemTemplate>
    <FooterTemplate>
      </ul>
    </FooterTemplate>
</asp:Repeater>

My ImageButton doesn't have a unique ID for each button, so in my ItemDataBound how do I detect my ImageButton so that I can perform some processing on each image button?

Thanks
0
Comment
Question by:directxBOB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 1600 total points
ID: 33444345
The ItemDataBound event will give you access to the row being bound. You an use FindControl("imgButton") to retrieve the ImageButton for the current row.
0
 
LVL 1

Assisted Solution

by:revteam
revteam earned 400 total points
ID: 33444360
In VB:
Public Sub Repeater_ItemDataBound(ByVal Sender As Object, ByVal e As RepeaterItemEventArgs) Handles Repeater1.ItemDataBound

  If e.Item.ItemIndex >= 0 Then
   Dim imgButton As ImageButton= CType(e.Item.FindControl("imgButton"), ImageButton)
    If imgButton  isNot NothingThen
      'do your processing
   End If
End If
EndSub

In C#
 protected void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemIndex > 0)
        {

            ImageButton imgButton = (ImageButton)e.Item.FindControl("imgButton");
         if (imgButton  != null)
 {

        //Do your processing
}

}
}
   
0
 
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 33444376
public void Repeater1_ItemCommand(object s, RepeaterCommandEventArgs e)
{
ImageButton ddl1 = (ImageButton )e.Item.FindControl("imgButton");
}
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question