Reputation: 3945
<mesh:SecurePanel runat="server" ID="retentionInvoiceDue" WebMasters="true" Admins="true" style="text-align:left; font-size:small;">
<a class="alert" ID="a1">Alerts</a>
<br>
<asp:Panel ID="panelToPromptRetentionInvoiceDue" runat="server"
CssClass="retentionLinksOnHomePage" Visible="true">
<asp:DataGrid ID="datagridToPromptRetentionInvoiceDue" runat="server"
AutoGenerateColumns="false" GridLines="None" ShowHeader="false">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<span>Site
<asp:LinkButton ID="promptRententionInvoiceLink" CommandArgument='<%# Bind ("id") %>' OnCommand="getSessionVariableForWorkSiteID" runat="server">
<asp:Label id="labelBindfromHomeToInvoice" runat="server" Text="<%# Bind('Site_Name') %>"/>
</asp:LinkButton>retention due for invoicing
</span>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</asp:Panel>
</mesh:SecurePanel>
In cs file I have in page load:
Context db = new Context();
var allWorkSites =
(from worksites in db.Work_Sites
select worksites).Distinct().ToList();
List<Object> chosenInvoicesForRetention = new List<Object>();
foreach (Work_Site worksite in allWorkSites)
{
if (!worksite.Invoicing_Complete)
{
Invoice lastInvoice = worksite.Invoices.OrderBy(w => w.id).LastOrDefault();
if (lastInvoice != null)
{
if (lastInvoice.Invoice_Date < DateTime.Now.AddMonths(0 - worksite.Number_of_Months))
{
chosenInvoicesForRetention.Add(worksite);
}
}
}
}
if (chosenInvoicesForRetention.Count == 0)
{
panelToPromptRetentionInvoiceDue.Visible = false;
}
else
{
datagridToPromptRetentionInvoiceDue.DataSource = chosenInvoicesForRetention;
datagridToPromptRetentionInvoiceDue.DataBind();
}
}
Why am I getting the error: panelToPromptRetentionInvoiceDue & datagridToPromptRetentionInvoiceDue does not exist??
EDIT: I should mention that this code works fine from a different page on my prject, i just copied it over as I want to use it again, but change the table it is being linked too...why would it work from one page and not another?
Also removed the secure panel but still doesnt work
Anyone have any ideas? Would be greatly appreciated
Upvotes: 0
Views: 67
Reputation: 18152
I assume you'll need to use FindControl
to reference any controls within the SecurePanel
.
Try placing the following above the places they're referenced in your code-behind.
var datagridToPromptRetentionInvoiceDue =
(DataGrid)retentionInvoiceDue.FindControl("datagridToPromptRetentionInvoiceDue");
var panelToPromptRetentionInvoiceDue =
(Panel)retentionInvoiceDue.FindControl("panelToPromptRetentionInvoiceDue");
Upvotes: 1