我正在开发一个公司网络应用程序。
我的ASP .NET GridView工作正常,但我不知道我做了什么改变使它停止显示行。它只显示一行或根本没有行。
这是我的代码:
private void BindAnnualLeaveGrid()
{
try {
string s = (string)Session["Status"];
if (s == null)
s = "Approved";
Employee emp = (Employee)Session["Employee"];
DataTable table = DataAccess.GetLeave("Annual", s, emp.Id);
this.gvUserAnnualLeave.DataSource = table;
this.gvUserAnnualLeave.DataBind();
Debug.WriteLine("this.gvUserAnnualLeave.Rows.Count=" + this.gvUserAnnualLeave.Rows.Count);
} catch (Exception ex) {
Debug.WriteLine(ex.StackTrace);
}
}
Debug.WriteLine行(" this.gvUserAnnualLeave.Rows.Count =" + this.gvUserAnnualLeave.Rows.Count);打印4行,所以在DATATABLE中有行。
任何帮助都将不胜感激。
这是ASPX代码:
<asp:Table ID="Table5" runat="server" Width="100%">
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="Label1" runat="server" Text="Annual Leave Summary" Font-Size="Small" ForeColor="#022439"></asp:Label>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:GridView ID="gvUserAnnualLeave" runat="server" CssClass="GridView"
ShowFooter="True" OnSelectedIndexChanged="gvUserAnnualLeave_SelectedIndexChanged"
AutoGenerateColumns="False" DataKeyNames="ItemID"
AllowPaging="True" OnPageIndexChanging="gvUserAnnualLeave_PageIndexChanging"
PageSize="15">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="ItemID" HeaderText="ItemID" SortExpression="ItemID" />
<asp:BoundField DataField="Absence" HeaderText="Absence" SortExpression="Absence" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="Comments" HeaderText="Comments" SortExpression="Comments" />
<asp:BoundField DataField="StartDate" dataformatstring="{0:dd-M-yyyy}" HeaderText="StartDate" SortExpression="StartDate" />
<asp:BoundField DataField="EndDate" dataformatstring="{0:dd-M-yyyy}" HeaderText="EndDate" SortExpression="EndDate" />
<asp:BoundField DataField="EmployeeID" HeaderText="EmployeeId" SortExpression="EmployeeID" />
<asp:BoundField DataField="Days" HeaderText="Days" SortExpression="Days" />
</Columns>
<FooterStyle BackColor="#022439" Font-Bold="True" ForeColor="White" />
<EmptyDataTemplate>
No Data To Display!
</EmptyDataTemplate>
</asp:GridView>
</asp:TableCell>
</asp:TableRow>
</asp:Table>