Tuesday, September 27, 2011

Find control in header template in repeater or any container

We can search any type of control in header templete through item_databound event of repeater like this.

protected void rptElective_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
Label lblSelect = (Label)e.Item.FindControl("lblSelect");
if (SpecFlag == false)
lblSelect.Visible = true;
else
lblSelect.Visible = false;
}

}

And also you can Hide Control without Item_dataBound like this enjoy coding...

Label lblSelect = rptElective.Controls[j].Controls[j].FindControl("lblSelect") as Label;

No comments:

Post a Comment