只有在按下时才需要更新数据行所需的C#gridview按钮字段

时间:2014-07-26 09:41:49

标签: c# asp.net gridview buttonfield

我现在正在做这个任务,我坚持这个问题,据我所知,我必须在gridview中添加一个buttonfield,当按下时,它会更新状态,并在我的数据库中减少FabricStock 。 我已经有了gridview,其他一切都已完成,我可以从我的sql中检索数据,现在留下了buttonfield,我该如何开始这样做? 我已经阅读了很多关于更新数据行的文章,但显然那些不是我想要的,而且我对buttonfield的了解是

这些是我的gridview aspx代码。

<asp:GridView ID="gvFabrics" runat="server" CellPadding="3" GridLines="None" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellSpacing="1" Font-Names="Lao UI" AutoGenerateColumns="False" Width="976px" AllowPaging="True" OnPageIndexChanging="gvFabrics_PageIndexChanging" PageSize="5">
        <Columns>
        <asp:BoundField DataField="ProductionPlanID" HeaderText="Production Plan ID" />
            <asp:BoundField DataField="FashionStyleID" HeaderText="Fashion Style ID" />
            <asp:BoundField DataField="FabricID" HeaderText="Fabric ID" />
            <asp:BoundField DataField="WarehouseID" HeaderText="Warehouse ID" />
            <asp:BoundField DataField="PPStatus" HeaderText="Status" />
            <asp:BoundField DataField="PPFabricReqd" HeaderText="PP Fabric Reqd" />
            <asp:BoundField DataField="PPFabricIssued" HeaderText="PP Fabric Issued" />
            <asp:ButtonField ButtonType="Button" HeaderText="Update Fabric" Text="Update" />
        </Columns>
        <FooterStyle BackColor="#C6C3C6" Font-Bold="True" ForeColor="Black" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
        <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
        <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
        <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F1F1F1" />
        <SortedAscendingHeaderStyle BackColor="#594B9C" />
        <SortedDescendingCellStyle BackColor="#CAC9C9" />
        <SortedDescendingHeaderStyle BackColor="#33276A" />
    </asp:GridView>`

                                                                                                                                                                                                                                                                                               `

1 个答案:

答案 0 :(得分:0)

编辑更新并在侧面gridview中删除。 This could help