我有一个FormView控件,我只需要“编辑”模式。这是我的代码
<asp:FormView ID="fvProposal" runat="server" Visible="True"
DataSourceID="sdsProposal"
DefaultMode="Edit">
<EmptyDataTemplate>
There is nothing to see here.
</EmptyDataTemplate>
<EditItemTemplate>
<span class="AttributeLabel">Title:</span>
<asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' />
<asp:RequiredFieldValidator runat="server" ControlToValidate="TitleTextBox" CssClass="reqfield" Text="*Required field." />
<br />
<span class="AttributeLabel">Description:</span>
<asp:TextBox ID="DescriptionTextBox" runat="server" TextMode="MultiLine" Text='<%# Bind("Description") %>' Width="40%" />
<br />
<span class="AttributeLabel">Funding Agency:</span>
<asp:TextBox ID="FundingAgencyTextBox" runat="server" Text='<%# Bind("FundingAgency") %>' />
<asp:RequiredFieldValidator runat="server" ControlToValidate="FundingAgencyTextBox" CssClass="reqfield" Text="*Required field." />
<br />
<span class="AttributeLabel">Submit for review:</span>
<asp:CheckBox ID="cbSubmit" runat="server" Checked='<%# Bind("Sub") %>'/> Check if you are ready to submit this proposal.
<br />
<span class="AttributeLabel">
<asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Proceed" />
</span>
<asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" PostBackUrl="MyProposals.aspx"/>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit my information" CssClass="button"/><br/>
<br/>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="sdsProposal" runat="server" ConnectionString="<%$ ConnectionStrings:cnIRBSS %>"
SelectCommand="SELECT [Title], [Description], [FundingAgency] FROM [Proposal] WHERE ProposalID=@PID"
UpdateCommand="UPDATE [Title] SET [Title] = @Title, [Description] = @Description, [FundingAgency] = @FundingAgency, [Submitted] = @Sub WHERE [ProposalID] = @PID">
<UpdateParameters>
<asp:SessionParameter SessionField="ProposalID" Name="PID" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="FundingAgency" Type="String" />
<asp:Parameter Name="Sub" Type="Boolean"/>
</UpdateParameters>
<SelectParameters>
<asp:SessionParameter SessionField="PID" Name="ProposalID" />
</SelectParameters>
</asp:SqlDataSource>
我的问题是,即使来自SQLDataSource的相同查询在SQLSMS中返回正确的数据,FormView也不会显示数据。我错过了什么和/或做错了什么?