Link to home
Start Free TrialLog in
Avatar of giligatech
giligatech

asked on

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)
        {
            count++;
            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?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of giligatech
giligatech

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial