2012-05-07 17 views
0

從我的gridview "gridPayments"我試圖刪除付款通過使用PaymentId,也試圖刪除選定的gridview行,因爲這是我的aspx腳本調用custom.js文件中的jQuery函數頁面一樣,從jQuery中刪除GridViewRow

<div class="close1" onclick="DeletePayment(<%# Container.DataItemIndex %>, 
              <%# Eval("PaymentId") %>);"></div> 

,並在DeletePayment方法正在接收這些衣被合計爲

function DeletePayment(index,paymentid) { 
//my code for deleting payment.. 
} 

paymentid我可以通過調用web服務中刪除我的付款jQuery,問題是我想要refresh the GridView after the successful deletion of Payment

我試圖像這種方法刪除gridview的行狀

index.remove(); 

,但它不工作,我不知道如何從這個jQuery的方法去除gridviewrow ......任何人都可以幫助我在這裏....

+0

jQuery運行在客戶端,並不知道任何關於GridViews,它只知道HTML表。 –

+0

謝謝史蒂夫,對於你的回覆 – shanish

回答

1

一種方法是這樣的:

在代碼隱藏的方法來刷新GridView的內容:

public void LoadGridViewData(){ // Blah... } 

在aspx頁面上,有一個ASP.NET Button,單擊它時將調用GridView數據刷新方法。

<asp:Button runat="server" ID="btnRefreshData" ClientIDMode="Static" OnClick="btnRefreshData_OnClick /> 

現在在代碼隱藏創建按鈕點擊方法:

public void btnRefreshData_OnClick(object sender, Eventargs e) 
{ 
    LoadGridViewData(); // This does the data binding stuff on the GridView. 
} 

最後,使用此Javascript刪除數據時,掛鉤按鈕點擊:

<script type="text/javascript"> 
    function DeletePayment(index,paymentid) { 
     // Do your deletion, and then finally..... 
     $("#btnRefreshData").click(); // This will call the server-side button click method. 
    } 
</script> 

現在我我不確定上述是否是100%,因爲我是從記憶中完成這項工作的,但總體思路是正確的。

+0

謝謝傑森,我會檢查 – shanish