sfr*_*frj 2 .net c# asp.net visual-studio
我刚从Visual Studio 2005收到此消息,当我点击删除命令时,我使用界面配置网格添加到我的gridview:
除非指定了DeleteCommand,否则数据源'transactionsSqlDataSource'不支持删除.
我怎么能激活它?我希望我的用户在单击"删除"按钮时能够删除一行.
我已经将我的SQLDataSource的属性DeleteCommandType更改为StoredProcedure.我还需要做什么?
UPDATE
这就是我所做的,但我遗漏了一些东西,我无法编译:
这就是我在.cs所做的:
public string DeleteCommand { get; set; }
Run Code Online (Sandbox Code Playgroud)
我怎么能解决这个问题,它说得到的是身体缺失.我不习惯使用ASP.NET.你能帮我修一下这部分代码吗?
这就是我在.aspx所做的:
<asp:SqlDataSource ID="transactionsSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:membershipsDBConnectionString %>"
SelectCommand="SELECT [brukerId], [kjoptekvoten], [pengeneutbetalt], [fyringsolje], [biltype], [kjoptid] FROM [Informasjon]" DeleteCommandType="StoredProcedure"
DeleteCommand="DELETE FROM [Informasjon] WHERE fyringsolje='Kull: 2,42 kg';">
</asp:SqlDataSource>
Run Code Online (Sandbox Code Playgroud)
数据源的配置是否正确?不要担心,如果你看到删除命令不使用上面的参数,它只是一个功课(我只需要通过查询).
更新2 我一直在尝试,但我无法解决它.我是ASP.NET的新手,我对所有术语都不是很熟悉.到底发生了什么?我如何知道我的商店程序的名称?:
CS:
public string DeleteCommand { get { return DeleteCommand; } set { DeleteCommand = "";}
Run Code Online (Sandbox Code Playgroud)
ASPX:
<asp:SqlDataSource ID="SqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:membershipsDBConnectionString %>"
DeleteCommandType="StoredProcedure" SelectCommand="SELECT [id], [kjoptekvoten], [pengeneutbetalt], [fyringsolje], [biltype], [kjoptid] FROM [Informasjon]"
DeleteCommand="StoredProcedureName">
</asp:SqlDataSource>
Run Code Online (Sandbox Code Playgroud)
当我单击Delete时,需要从表Informasjon中删除该行

DeleteCommand="<your stored proc>"
Run Code Online (Sandbox Code Playgroud)
在您的SqlDataSource中需要您需要的任何参数,例如:
<DeleteParameters>
<asp:Parameter Name="myParameter" Type="Int32" />
</DeleteParameters>
Run Code Online (Sandbox Code Playgroud)
需要在SqlDatasource标记中添加.
| 归档时间: |
|
| 查看次数: |
7454 次 |
| 最近记录: |