<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>
在CS文件我已經在頁面加載:不能綁定到datagrid?
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();
}
}
爲什麼我得到的錯誤: panelToPromptRetentionInvoiceDue & datagridToPromptRetentionInvoiceDue不存在?
編輯: 我應該指出,這個代碼工作正常,從我的prject不同的頁面,我只是複製過來,我想再次使用它,但改變它被鏈接過多表..爲什麼它會從一頁而不是另一頁工作?
也去掉了安全面板,但仍然不工作
人有什麼想法?將不勝感激
什麼是''如果用戶控制,那麼你有正確的註冊它在頁面上。 –
Sachin
2013-03-03 16:06:39
是它的用戶控制 – John 2013-03-03 16:08:04