我正在尝试使用 SqlDataSource 导入动态数据的 gridview ,加上 2 个包含 2 个按钮的 TemplateFields 作为Accept和Decline。我需要做的是,更新记录来自的表的特定列。(更改从 Null 到 1 或 0 的值,在名为“已接受”的列中)
Q.)我需要一种方法来识别将单击按钮的行吗?(需要识别特定行的访问键值)
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="request_no" DataSourceID="SqlDataSource1" Font-Names="Tahoma" Font-Size="Small" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged1" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="request_no" HeaderText="request_no" ReadOnly="True" SortExpression="request_no" />
<asp:BoundField DataField="employee_name" HeaderText="employee_name" SortExpression="employee_name" />
<asp:BoundField DataField="requested_date" HeaderText="requested_date" SortExpression="requested_date" />
<asp:BoundField DataField="requested_time" HeaderText="requested_time" SortExpression="requested_time" />
<asp:BoundField DataField="requested_from" HeaderText="requested_from" SortExpression="requested_from" />
<asp:BoundField DataField="requested_to" HeaderText="requested_to" SortExpression="requested_to" />
<asp:BoundField DataField="service_type" HeaderText="service_type" SortExpression="service_type" />
<asp:BoundField DataField="reason_data" HeaderText="reason_data" SortExpression="reason_data" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="AcceptRequest" runat="server" OnClick="AcceptRequest_Click" Text="Accept" CommandName="AcceptRequestcmd" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="DeclineRequest" runat="server" OnClick="DeclineRequest_Click" Text="Decline" CommandName="DeclineRequestcmd" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>