Gridview在页面加载时不显示

时间:2011-04-05 09:20:39

标签: .net asp.net gridview sqldatasource

即使我已将gridview与数据源绑定,页面加载时也不显示gridview ....下面是代码...请帮助

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DSF_View_ChangeRequest.aspx.cs" Inherits="DSF_View_ChangeRequest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
            <tr>
            <td align="center" class="style9" style="font-size: 1pt;">
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:QualityManagerConnectionString %>" 
                SelectCommand="SELECT TOP (100) PERCENT dbo.NCB_ProjectDashBoardView.ProjectNum, dbo.NCB_ChangeRequest.RequestNum, dbo.NCB_ChangeRequest.RequestStatus, dbo.NCB_ProjectDashBoardView.ProjectName, dbo.NCB_Release_DashBoardData.QA_Planned_EndDate, DATEPART(YEAR, dbo.NCB_Release_DashBoardData.QA_Planned_EndDate) AS Expr1, CASE WHEN IPMRefNum &lt;&gt; ProjectNum THEN IPMRefNum ELSE NULL END AS IPMRefNum, dbo.NCB_ProjectDashBoardView.ProposedPhaseName, dbo.NCB_ProjectDashBoardView.DependencyList FROM dbo.NCB_ProjectDashBoardView INNER JOIN dbo.NCB_Release_DashBoardData ON dbo.NCB_ProjectDashBoardView.ProjectNum = dbo.NCB_Release_DashBoardData.RequestNum INNER JOIN dbo.NCB_ChangeRequest ON dbo.NCB_ProjectDashBoardView.ProjectNum = LEFT (dbo.NCB_ChangeRequest.RequestNum, 7) WHERE (dbo.NCB_Release_DashBoardData.QA_Category = N'Release Handover') AND (dbo.NCB_Release_DashBoardData.QA_Planned_EndDate &gt; @param1) AND (dbo.NCB_Release_DashBoardData.QA_Planned_EndDate &lt; @param2) AND (dbo.NCB_ChangeRequest.RequestStatus &lt;&gt; 'Rejected') AND (dbo.NCB_ChangeRequest.RequestStatus &lt;&gt; 'Closed') ORDER BY dbo.NCB_ProjectDashBoardView.ProjectNum DESC">
                    <SelectParameters>
                        <asp:Parameter Name="param1" />
                        <asp:Parameter Name="param2" />
                    </SelectParameters>
            </asp:SqlDataSource>
                <br />
                <asp:ImageButton ID="ImageButton_Hdr_Help" runat="server" ImageUrl="~/Images/NCBLogo_QAManager_Trend_Dashboard.png"
                    OnClick="ImageButton_Hdr_Help_Click" />
            </td>
        </tr>
                            <tr>
                        <td style="font-size: 10pt; text-align: left" class="style6">
                            &nbsp;
                        </td>
                        <td style="font-size: 10pt; text-align: left;" class="style14">
                            &nbsp;
                        </td>
                        <td style="font-size: 10pt; text-align: left; color: #FFFFFF;" class="style3">
                            &nbsp;
                        </td>
                        <td style="font-size: 10pt; width: 218px; text-align: left; height: 19px;">
                        </td>
                    </tr>


<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" 
    GridLines="None">
    <RowStyle BackColor="#EFF3FB" />
    <Columns>
        <asp:BoundField DataField="ProjectNum" HeaderText="ProjectNum" 
            SortExpression="ProjectNum" />
        <asp:BoundField DataField="RequestNum" HeaderText="RequestNum" 
            SortExpression="RequestNum" />
        <asp:BoundField DataField="RequestStatus" HeaderText="RequestStatus" 
            SortExpression="RequestStatus" />
        <asp:BoundField DataField="ProjectName" HeaderText="ProjectName" 
            SortExpression="ProjectName" />
        <asp:BoundField DataField="QA_Planned_EndDate" HeaderText="QA_Planned_EndDate" 
            SortExpression="QA_Planned_EndDate" />
        <asp:BoundField DataField="Expr1" HeaderText="Expr1" ReadOnly="True" 
            SortExpression="Expr1" />
        <asp:BoundField DataField="IPMRefNum" HeaderText="IPMRefNum" ReadOnly="True" 
            SortExpression="IPMRefNum" />
        <asp:BoundField DataField="ProposedPhaseName" HeaderText="ProposedPhaseName" 
            SortExpression="ProposedPhaseName" />
        <asp:BoundField DataField="DependencyList" HeaderText="DependencyList" 
            ReadOnly="True" SortExpression="DependencyList" />
    </Columns>
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <EditRowStyle BackColor="#2461BF" />
    <AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
</form>
</body>
</html>

1 个答案:

答案 0 :(得分:3)

我认为你没有传递选择参数

               <SelectParameters>
                    <asp:Parameter Name="param1" />
                    <asp:Parameter Name="param2" />
                </SelectParameters>