2013-03-10 18 views
-1

正如標題所說,我有一個簡單的5列/ 5rows GridView,它代表了asp.net中的購物車。我需要使用JavaScript來刪除選中的行和按鈕單擊上的所有行。這怎麼可能完成?當物品被移除時,總價格也應該改變。 Thx提前。使用javascript從gridview中刪除selected/all行

這是示例代碼的aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Kosarica.aspx.cs" Inherits="Spletna_kosarica_2.Kosarica" EnableSessionState="True" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 

     <h2>Kosarica:</h2> 
     <p> 
      <asp:GridView ID="GridView1" runat="server" Width="440px" 
       AutoGenerateSelectButton="True"> 
      </asp:GridView> 
     </p></div> 
    &nbsp;<asp:Button ID="Button2" runat="server" onclick="Button2_Click" 
     Text="Dodaj artikel" Width="143px" /> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    <asp:Button ID="Button3" runat="server" Text="Remove" /> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    <asp:Label ID="Label1" runat="server" Text="Total price:"></asp:Label> 
&nbsp;<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> 
    </form> 
</body> 
</html> 
+0

關於Web服務的視頻教程,您需要發佈一些代碼之前,我們可以幫助你。 – 2013-03-10 15:59:45

回答

0

您需要使用Web服務與服務器+ AJAX進行通信。 Javascript不能單獨做這件事,因爲它運行在客戶端瀏覽器中。

有很多指南,文件,教程等,更深入地解釋這個問題。有多種方式可以做到這一點,您只需選擇適合您的情況和技能的最佳方式即可。

這是在asp.net http://www.asp.net/web-forms/videos/how-do-i/how-do-i-create-and-call-a-simple-web-service-in-aspnet

+0

你能提供任何有用的鏈接,這就解釋了一件簡單的事情嗎?我搜索了一些,只有很大的代碼,我還不明白。 – cvenko 2013-03-10 16:05:58

+0

@cvenko,已更新。如果它還不夠,只需使用Google,我敢打賭,只需輸入simple,就可以找到數千條記錄:'asp.net webservice' – walther 2013-03-10 16:15:47