单击按钮后,为什么GridView中的Previous内容会消失

时间:2017-08-06 19:23:49

标签: c# asp.net

我正在尝试使用asp.net创建一个Web应用程序。我从数据库中获取一些数据,并在按钮单击事件上将其绑定到GridView。这是源文件:

$color-style-winter: #11111;
$color-style-christmas: #22222;

$styles: 'winter' 'hills',
  'christmas' 'xmas';

@each $name, $image in $styles {
    .style-#{$name} {
        background: url('../../images/styles/#{$image}.jpg');
    }

    a {
        color: $color-style- + $name;
    }
}

以下是文件背后的代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Order.aspx.cs" Inherits="Order" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .auto-style2 {
            width: 100%;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table class="auto-style2">
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="lbl_Name" runat="server" Text="Name"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txt_Name" runat="server"></asp:TextBox>
            </td>
            <td rowspan="4">
                <asp:GridView ID="GridViewCart" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" Width="100%" ViewStateMode="Enabled">
                    <AlternatingRowStyle BackColor="White" />
                    <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
                    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                    <SortedAscendingCellStyle BackColor="#FDF5AC" />
                    <SortedAscendingHeaderStyle BackColor="#4D0000" />
                    <SortedDescendingCellStyle BackColor="#FCF6C0" />
                    <SortedDescendingHeaderStyle BackColor="#820000" />
                </asp:GridView>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="lbl_Contact" runat="server" Text="Contact"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txt_Contact" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="lbl_Item" runat="server" Text="Item"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="ddl_select_item" runat="server">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="lbl_Quantity" runat="server" Text="Quantity"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txt_Quantity" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
                <asp:Button ID="btn_AddCart" runat="server" OnClick="btn_AddCart_Click"  Text="Add To Cart" />
            </td>
            <td>
                <asp:Button ID="btn_PlaceOrder" runat="server" Text="Place Order" />
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
    </table>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</asp:Content>

我的问题是每次按下&#34;添加到购物车&#34;按钮当前所选数据从下拉列表中显示在GridView中,而不是之前的。我需要将数据与之前的数据一起附加到GridView中。 My first selection and "Add to cart" button click

My second selection from drop down and "Add to cart" button click

0 个答案:

没有答案