Reputation: 49
There is repeater in my program includin a hyper link.i cant a cess my hyper link control.
<asp:HyperLink ID="HyperLink15" runat="server" NavigateUrl="abc.aspx">
set enabled=false
so i use
HyperLink a = (HyperLink)Repeater1.FindControl("HyperLink15");
The hyper link is only enabled for user a and b... so i use the code:
if (a && b)
{
HyperLink link = (HyperLink)Repeater1.FindControl("HyperLink15");
link.Enabled=true;
link.Navigateurl="efg.aspx";
}
But I get the following error:
System.NullReferenceException: Object reference not set to an instance of an object.
Upvotes: 0
Views: 1940
Reputation: 11309
Repeater onItemDataBound Event
first check below condition.
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
// find controls here
}
Upvotes: 2
Reputation: 5727
HyperLink a = (HyperLink)Repeater1.Items[0].FindControl("HyperLink15");
Use above, and Items will contain index.
Or
for (int count = 0; count < Repeater1.Items.Count; count++)
{
HyperLink a = (HyperLink)Repeater1.Items[count].FindControl("HyperLink15");
}
Upvotes: 2