【发布时间】:2014-08-05 12:45:21
【问题描述】:
你好,这是我的代码,我正在尝试修复它并用谷歌搜索,但我找不到答案。
这是我的 SqlDataSource:
<asp:SqlDataSource
id="SqlDataSource1"
runat="server"
ConnectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\xxx.mdf;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework"
SelectCommand="SELECT * FROM JarkomTable"
UpdateCommand="UPDATE JarkomTable SET [Nama]=@Nama, [Kode]=@Kode WHERE [Id]=@Id"
DeleteCommand="DELETE FROM JarkomTable WHERE [Id]=@Id">
<UpdateParameters>
<asp:Parameter Name="Id" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="Id" />
</DeleteParameters>
</asp:SqlDataSource>
这是我的 GridView:
<asp:GridView
id="GridView1"
runat="server"
DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField HeaderText="Id" DataField="Id" />
<asp:BoundField HeaderText="Nama" DataField="Nama" />
<asp:BoundField HeaderText="Kode" DataField="Kode" />
<asp:CommandField ShowDeleteButton="True" ButtonType="Button" />
<asp:CommandField ShowEditButton="True" ButtonType="Button" />
</Columns>
我可以使用更新命令,但不知何故,当我单击删除按钮时,它总是出现“必须声明标量变量“@Id””错误。请帮助我:“我很沮丧
抱歉英语不好,谢谢
【问题讨论】:
标签: c# asp.net gridview webforms