asp.net gridview。使用DeleteCommand作为updatecommand?

时间:2017-03-16 15:03:31

标签: javascript c# asp.net .net gridview

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$    ConnectionStrings:DbConnection %>" 
    SelectCommand="SELECT [userid],[loginid], [password], [contactname], [phone], [zip], [state], [city], [address], [companyid], [email] FROM [users] where [active]=1"
    UpdateCommand="Update [users] set [loginid]=@loginid, [password]=@password, [contactname]=@contactname, [phone]=@phone, [zip]=@zip, [state]=@state, [city]=@city, [address]=@address, [companyid]=@companyid, [email]=@email where [userid]=@userid"
    DeleteCommand="UPDATE [dbo].[users] SET     [active] = 0 WHERE userid=@userid">
</asp:SqlDataSource> 

您好我正在尝试教程,他们有一个基本的开箱即用的gridview命令autogenerateDelete和autogenerateEdit。

我的问题是

  1. 我喜欢编辑/更新/取消按钮。有没有办法让我不需要选择要在gridview上显示的主键(userid)才能使这些命令有效?
  2. 我想使用autogenerateDelete按钮作为更新按钮,但它不起作用。我只想设置active = 0而不是实际删除行是否可能?我得到错误&#34; System.Data.SqlClient.SqlException:必须声明标量变量&#34; @ userid&#34;。& #34;

0 个答案:

没有答案