我设置了一个 Sqldatasource 和一个 Gridview:
<asp:SqlDataSource ID="DetailsSQLDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:aspnet-WebApplication6-20131007103938ConnectionString1 %>"
SelectCommand="SELECT [ProjectID], [ProjectName], [CreatorID], [Deadline] FROM [tProject] WHERE 1=1"
>
<SelectParameters>
<asp:Parameter Type="String" Name="ProjectID"></asp:Parameter>
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" DataSourceID="DetailsSQLDataSource" AutoGenerateColumns="False" DataKeyNames="ProjectID" OnRowUpdated="GridView1_RowUpdated" OnRowUpdating="GridView1_RowUpdating">
<Columns>
<asp:BoundField DataField="ProjectID" HeaderText="ProjectID" ReadOnly="True" SortExpression="ProjectID"></asp:BoundField>
<asp:BoundField DataField="ProjectName" HeaderText="ProjectName" SortExpression="ProjectName"></asp:BoundField>
<asp:BoundField DataField="CreatorID" HeaderText="CreatorID" SortExpression="CreatorID"></asp:BoundField>
<asp:BoundField DataField="Deadline" HeaderText="Deadline" SortExpression="Deadline"></asp:BoundField>
</Columns>
</asp:GridView>
我已经测试了 selectcommand,它返回一个有 4 行的表。然而,gridview 中没有可显示的数据。代码隐藏几乎是空的,肯定不会影响这些控件。可能与连接有关吗?我该如何测试呢?