FindControl() Doesn't work

Hi, I have 3 buttons:

    <asp:Button runat="server" ID="btnSiteDiscount1" onclick="btnSiteDiscount1_Click" />
    <asp:Button runat="server" ID="btnSiteDiscount2" onclick="btnSiteDiscount2_Click" />
    <asp:Button runat="server" ID="btnSiteDiscount3" onclick="btnSiteDiscount3_Click" />

On my PageLoad() i have this code:

        int count = 0;
        foreach (x in y)
            Button btn = (Button)this.FindControl("btnSiteDiscount" + count);
            btn.Text = "xxxxxxx";

The problem is that btn == null! why is that and how do I fix it?

Who is Participating?
giligatechConnect With a Mentor Author Commented:
I forgot to say that I'm working on a page that has Masterpage.
Enetually I figured it and the solution is:

Button btn = (Button)this.Master.FindControl("GeneralContent").FindControl("btnSiteDiscount" + count);

is there another solution?
All Courses

From novice to tech pro — start learning today.