如何将 GridView 中行的 id 链接到 deletecommand 以删除一行?
这是我的代码:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False">
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:BoundField DataField="SDate" HeaderText="SDate" SortExpression="SDate" />
<asp:BoundField DataField="STime" HeaderText="STime" SortExpression="STime" />
<asp:BoundField DataField="SPrice" HeaderText="SPrice"
SortExpression="SPrice" />
<asp:BoundField DataField="SDuration" HeaderText="SDuration"
SortExpression="SDuration" />
<asp:BoundField DataField="SNoPlaces" HeaderText="SNoPlaces"
SortExpression="SNoPlaces" />
<asp:BoundField DataField="ScheduleId" HeaderText="ScheduleId"
InsertVisible="False" ReadOnly="True" SortExpression="ScheduleId" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ChinatowndbConnString %>"
DeleteCommand="DELETE FROM Schedule WHERE (ScheduleId = @ScheduleId)"
SelectCommand="SELECT SDate, STime, SPrice, SDuration, SNoPlaces, ScheduleId FROM Schedule">
<DeleteParameters>
<asp:Parameter Name="ScheduleId" />
</DeleteParameters>
</asp:SqlDataSource>
我正在使用 Visual Studio 2010。