使用4.5和C#构建ASP网站。我使用gridview来显示我的数据库记录,启用了更新/删除按钮。一切工作正常,除了删除按钮。我收到以下错误:删除列错误
从所需参数中缺少一个或多个值。
我看到的Delete命令的唯一参数是UserID,我不确定我错过了什么。
任何人有任何想法? 谢谢。
<asp:GridView ID="grdUsers" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="UserID" HeaderText="UserID" InsertVisible="False" SortExpression="UserID" />
<asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" />
<asp:BoundField DataField="UserPassword" HeaderText="UserPassword" SortExpression="UserPassword" />
<asp:BoundField DataField="SecurityLevel" HeaderText="SecurityLevel" SortExpression="SecurityLevel" />
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [tblUserLogin]" OnSelecting="SqlDataSource1_Selecting"
DeleteCommand="DELETE FROM [tblUserLogin] WHERE [UserID] = ?"
UpdateCommand="UPDATE [tblUserLogin] SET [UserName] = ?, [UserPassword] = ?, [SecurityLevel] = ? WHERE [UserID] = ?">
<DeleteParameters>
<asp:Parameter Name="UserID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="UserPassword" Type="String" />
<asp:Parameter Name="SecurityLevel" Type="Char" />
</UpdateParameters>
</asp:SqlDataSource>
是updateCommand工作吗? – Dreamweaver