我有2个图像按钮,接受和拒绝。 “接受”按钮将[状态]更新为1 拒绝按钮将[状态]更新为2
我已成功使用UpdateCommand更新“接受”按钮
UpdateCommand="UPDATE [bookingschedule] SET status='1'WHERE [bookingScheduleID] = @bookingScheduleID"
但是,我不知道如何为Reject按钮设置更新命令,因为我只能声明一次UpdateCommand。
UpdateCommand2="UPDATE [bookingschedule] SET status='2'WHERE [bookingScheduleID] = @bookingScheduleID" (incorrect)
如何使拒绝按钮功能?我应该在哪里放置第二个更新命令行:
UpdateCommand="UPDATE [bookingschedule] SET status='2'WHERE [bookingScheduleID] = @bookingScheduleID"
我在客户端进行所有这些编码:
接受按钮
<asp:TemplateField HeaderText="Action Approve">
<ItemTemplate>
<asp:ImageButton runat="server" ID="UpdateCommand"
CommandName="update" ImageUrl="~/images/accept.png"
OnClientClick="if (!window.confirm('Are you sure you want to approve this booking?')) return false;" />
</ItemTemplate>
</asp:TemplateField>
拒绝按钮:
<asp:TemplateField HeaderText="Action Reject">
<ItemTemplate>
<asp:ImageButton runat="server" ID="UpdateCommand" CommandName="update" OnClick="reject"
ImageUrl="~/images/reject.png"
OnClientClick="if (!window.confirm('Are you sure you want to reject this booking?')) return false;" />
</ItemTemplate>
</asp:TemplateField>
SQL数据源:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
SelectCommand="SELECT [bookingScheduleID], [eventTitle], [week1], [week2], [week3], [week4], [week5], [week6], [week7], [week8], [exhibitorname], [boothAlias], [category], [status], [dateBook],[custNo] FROM [booking_all]"
UpdateCommand="UPDATE [bookingschedule] SET status='1'WHERE [bookingScheduleID] = @bookingScheduleID"
>
</asp:SqlDataSource>
<UpdateParameters>
<asp:Parameter Name="bookingScheduleID" Type="Int32" />
</UpdateParameters>
答案 0 :(得分:0)
使用控件根据点击的按钮动态存储/传递状态
UpdateCommand="UPDATE [bookingschedule] SET status=@Status WHERE [bookingScheduleID] = @bookingScheduleID"
然后添加
<asp:ControlParameter Name="Status" ControlID="StatusSelectionControl" PropertyName="Text" Type="Int32" />
propertyName应该是相对于使用的控件 - 我假设TextBox,但你也可以使用隐藏字段