1
如何將GridView中的行的id鏈接到deletecommand以便刪除一行?如何在GridView中刪除
這裏是我的代碼:
<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中