Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

access control inside repeater

Status
Not open for further replies.

bobetko

Programmer
Jan 14, 2003
155
US
How can I access control inside repeater's footer template.

Code:
<asp:Repeater ID="RptImages" runat="server">
...
...
<FooterTemplate>
 <asp:LinkButton ID="linkPrev" CommandName="prev"
    OnCommand="PaginationClicked_Command" 
    runat="server">Prev</asp:LinkButton>
 <asp:LinkButton ID="linkNext"  CommandName="next"
    OnCommand="PaginationClicked_Command"
    runat="server">Next</asp:LinkButton>
 <asp:Label ID="lblCounter" runat="server"
    Width="100px"></asp:Label>                        
</FooterTemplate>
</asp:Repeater>

I have tried
Code:
LinkButton lkPrev = (LinkButton)RptImages.FindControl("linkPrev");
lkPrev.Enabled = false;

But control can't be find and null is returned.

thanks to all.
 
Try this:
Code:
private void RptImages_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) 
{ 
 if (e.Item.ItemType.Footer) { 
   LinkButton lkPrev = ((LinkButton)(RptImages.FindControl("linkPrev"))); 
 } 
}

Jim
 
For this line:
Code:
if (e.Item.ItemType.Footer) ....

I got error: "Cannot implicitly convert ...ListItemType to 'bool'" I guess there should be other way to test footer?

Thanks

 
thanks, but anyway it doesn't work.
Code:
protected void RptImages_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
  if (e.Item.ItemType == ListItemType.Footer)
  {
    LinkButton lPrev = ((LinkButton)(RptImages.FindControl("linkPrev")));
    lPrev.Enabled = false;
   }
}

lprev is always NULL and I am receiving an error.
 
Ok, I got it....
A little change was needed "e.Item" instead "RptImages". No wonder it didn't work.

Thanks a lot Jim.

Code:
protected void RptImages_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
  if (e.Item.ItemType == ListItemType.Footer)
  {
    LinkButton lPrev = ((LinkButton)([b]e.Item.[/b]FindControl("linkPrev")));
    lPrev.Enabled = false;
   }
}
 
try
Code:
System.Web.UI.WebControls.LinkButton oLabel;
				oLabel = ((System.Web.UI.WebControls.LinkButton )(e.Item.FindControl("linkPrev")));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top