Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jquery或javascript从listview中删除项_Javascript_Jquery_Asp.net_Listview - Fatal编程技术网

使用jquery或javascript从listview中删除项

使用jquery或javascript从listview中删除项,javascript,jquery,asp.net,listview,Javascript,Jquery,Asp.net,Listview,我有下面的列表视图,我想在用户按下“添加到购物车”按钮时删除一个项目。我不能百分之百确定listview是如何工作的,因为ID必须是唯一的,正如您所知道的,ID为gameRow的表行将不会是唯一的。我想要实现的是,当用户按下“添加到购物车”按钮时,删除该游戏行中的所有tr 我正在使用asp listview并通过selectmethod填充它 <asp:ListView ID="lvProductListing" ItemType="CommonBusiness

我有下面的列表视图,我想在用户按下“添加到购物车”按钮时删除一个项目。我不能百分之百确定listview是如何工作的,因为ID必须是唯一的,正如您所知道的,ID为gameRow的表行将不会是唯一的。我想要实现的是,当用户按下“添加到购物车”按钮时,删除该游戏行中的所有tr

我正在使用asp listview并通过selectmethod填充它

<asp:ListView ID="lvProductListing"
              ItemType="CommonBusinessObjectsGS.Game"
              SelectMethod="GetGames"
              DataKeyNames="GameId"
              runat="server" EnableViewState="false"   >
    <LayoutTemplate>
        <table id="productListingTable" class="productLisingTable">
            <tr id="itemPlaceholder" runat="server"></tr>
        </table>
    </LayoutTemplate>
    <ItemTemplate>
        <tr id="gameRow">
        <tr>
            <td rowspan="6">
                <img class="gameImageIdClass" id="gameImageId" src="<%#:Item.GameImageString%>" alt="" />
            </td>
        </tr>

        <tr>
            <td><%#:Item.GameName%></td>
        </tr>
        <tr>
            <td><%#:Item.PlatformName%></td>
        </tr>
        <tr>
            <td><%#:Item.ConditionShortDescription%></td>
        </tr>
        <tr>
            <td><%#:Item.RetailCost.ToString("c")%></td>
        </tr>
        <tr>
            <td>
                <button id="btnAddToCart" name="btnAddToCart" onclick="removeGameRow()" value="<%#:Item.GameId %>">Add to Cart</button>
            </td>
        </tr>
        </tr>
    </ItemTemplate>
</asp:ListView>

“alt=”“/>
添加到购物车

我最后更改了html,使之更简单。下面是我的listview项目模板的外观。在CSS的帮助下(下图),gameImageDiv和gameInfoDiv将并排出现

    <ItemTemplate>
        <div id="gameContainerDiv">
            <div id="gameImageDiv">
                <img class="gameImageIdClass" id="gameImageId" src="<%#:Item.GameImageString%>" alt="" />
            </div>
            <div id="gameInfoDiv">
                <ul id="gameInfoUL">
                    <li><%#:Item.GameName%></li>
                    <li><%#:Item.PlatformName%></li>
                    <li><%#:Item.ConditionShortDescription%></li>
                    <li><%#:Item.RetailCost.ToString("c")%></li>
                    <li><button type="button" id="btnAddToCart" name="btnAddToCart" onclick="removeGameRow(this)" value="<%#:Item.GameId %>">Add to Cart</button></li>
                </ul>
            </div>
        </div>
    </ItemTemplate>