我不知道如果我做錯了什麼,但我想做什麼,是顯示我們從數據庫中檢索到的註冊表數量,並將其顯示在我們的頁腳上,有「總申請人:(在這裏我們應該能夠看到項目的總數)」,但我甚至不能調用asp:label來加載它.aspx.cs。這裏是我的代碼(標籤應該是lblTotal)FooterTemplate無法在我的.aspx.cs中調用任何函數
<blockquote>
<asp:GridView ID="gvApplicants" runat="server" AllowPaging="True" AllowSorting="true"
AutoGenerateColumns="False" DataKeyNames="Id" CellPadding="5" ForeColor="#333333"
GridLines="None" PageSize="10" ShowFooter="True" Width="100%" Font-Size="9pt"
OnSorting="gvApplicants_Sorting" OnPageIndexChanging="gvApplicants_PageIndexChanging">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True"
SortExpression="Id" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" />
<asp:TemplateField HeaderText="Complete Name" SortExpression="FirstName">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
<ItemTemplate>
<a href='candidato.aspx?key=<%#Eval("Key")%>'>
<%# Eval("FirstName") %>
<%# Eval("MiddleName") %>
<%# Eval("LastName") %>
<%# Eval("SecondLastName") %></a>
<br />
<small><%# GetLabels(Eval("Id").ToString())%></small>
</ItemTemplate>
<FooterTemplate>
Total candidates: <asp:Label ID="lblTotal" runat="server"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Vacancies" SortExpression="">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" />
<ItemTemplate>
<%# GetVacante(Eval("email").ToString())%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Status.Nombre" HeaderText="Status"
SortExpression="Status.Nombre" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Top" />
<asp:TemplateField HeaderText="Created Date" SortExpression="CreatedDate">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("createdDate", "{0:MMMM dd, yyyy. H:mm}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Rating" HeaderText="Rating" SortExpression="Rating" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Top" />
</Columns>
和.aspx.cs
private void LoadApplicants(Entity.Vacante v)
{
try
{
ASF.HC.JobApplication.BO.User u = new BO.User();
gvApplicants.DataSource = u.GetAllByVacancy(v);
gvApplicants.DataBind();
LoadData()
}
catch(Exception ex)
{
this.lblError.Text = "There was an unexpected error getting applicants: " + ex.Message;
}
}
protected void LoadTotal()
{
foreach (GridViewRow row in gvApplicants.Rows)
{
if (row.RowType == DataControlRowType.Footer)
{
Label myLabel = row.FindControl("lblTotal") as Label;
if (myLabel != null)
{
myLabel.Text = "hola";
}
}
}
}
「傢伙」......你知道有女性開發者嗎? – Fuzzybear
我的意思是男性和女性一樣。夥計們和加爾斯對我來說似乎並不實際。 –