Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
my div is in repeater ,

Please Let me know how to findcontrol div in code behind
Posted
Updated 2-Jun-14 0:32am
v2
Comments
[no name] 2-Jun-14 5:58am    
Hi...
Use div tag id or classname for find specific div tag.
Thank u.
Kornfeld Eliyahu Peter 2-Jun-14 6:11am    
Please read here to understand how element id works inside ASP.NET templates:
http://www.codeproject.com/Articles/775111/Understanding-ASP-NET-Templates

u need to loop through the repeater and then get the id of the div... make sure to add runat=server in the div

C#
foreach (RepeaterItem item in rptItems.Items)
{
    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
    {
        System.Web.UI.HtmlControls.HtmlGenericControl yourDiv= (System.Web.UI.HtmlControls.HtmlGenericControl)item.FindControl("yourDiv");

        //Do something with your yourDiv...

    }
}
 
Share this answer
 
Try this one friend.......

------------
Aspx Page
------------

<asp:label id="_lbl" runat="server" text="Check" xmlns:asp="#unknown">
<asp:button id="_btn" runat="server" text="Hit..." onclick="_btn_Click" xmlns:asp="#unknown">



------------
Code Behind .cs file which find control
------------

protected void _btn_Click(object sender, EventArgs e)
{
Label lbl=(Label)_d.FindControl("_lbl");
lbl.Text = "Hiiiiiiiiiiiiiiiii";
}

Enjoy solution :):):)........
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900