We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,089 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

adding link to a repeater

in html

<div id="dvEmpName" class="w200s">
                                <a href="#" id="basic" runat="server"><%# Eval("suppname")%></a></div>

here href id is basic which is used for the java script function

so in code add repeater itemdatabound event  


  protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem rowItem = e.Item;

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                HtmlControl btn = e.Item.FindControl("basic") as HtmlControl;
                HtmlControl rowContainer = e.Item.FindControl("dvRowData") as HtmlControl;

                if (btn != null)
                {
                    btn.Attributes.Add("onClick", string.Format("showDataRow('{0}');", rowContainer.ClientID));
                }
            }
        }
2
Contributors
1
Reply
3 Hours
Discussion Span
1 Year Ago
Last Updated
2
Views
weblion
Newbie Poster
Banned
19 posts since Feb 2012
Reputation Points: -1
Solved Threads: 0
Skill Endorsements: 0

Please refrain from putting JavaScript in your code behind. If you want to bind a JavaScript event to an element, do it in JavaScript.

Keep JavaScript separate from your page (keep in an external file)
Keep CSS separate (no inline styles, keep in external file)
HTML pages should only have HTML with references to the other resources need (js and css files).

This will also make it easier to debug later on.

Also instead of using HTMLControls, you might find it easier to use the server controls instead.

stbuchok
Practically a Posting Shark
876 posts since May 2011
Reputation Points: 138
Solved Threads: 124
Skill Endorsements: 2

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.1095 seconds using 2.67MB