【问题标题】:Remove GridViewRow from jQuery从 jQuery 中删除 GridViewRow
【发布时间】:2012-05-07 12:10:38
【问题描述】:

在我的gridview "gridPayments" 中,我正在尝试使用PaymentId 删除付款,并且我也在尝试删除选定的gridview 行,因为这正在从我的custom.js 文件中调用jQuery 函数aspx 脚本页面之类的,

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

并且在 DeletePayment 方法中接收这些值

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

使用paymentid,我可以通过从我的jQuery 调用网络服务来删除付款,问题是我想refresh the GridView after the successful deletion of Payment

我试过像从这个方法中删除gridview行一样

index.remove();

但它不起作用,我不知道如何从这个 jQuery 方法中删除 gridviewrow...任何人都可以在这里帮助我....

【问题讨论】:

  • jQuery 在客户端运行,对 GridViews 一无所知,它只知道 HTML 表格。
  • 感谢史蒂夫,您的回复

标签: jquery asp.net gridview


【解决方案1】:

一种方法是:

在您的代码隐藏中有一个方法来刷新 GridView 的内容:

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

在 aspx 页面上,有一个 ASP.NET 按钮,单击该按钮将调用 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%,因为我是凭记忆做的,但总体思路是合理的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-23
    • 1970-01-01
    • 1970-01-01
    • 2016-05-21
    • 1970-01-01
    • 1970-01-01
    • 2012-11-05
    • 2021-03-28
    相关资源
    最近更新 更多