【问题标题】:Asp net grid view select row using jquery使用 jquery 的 Asp 网络网格视图选择行
【发布时间】:2012-02-20 12:59:59
【问题描述】:

我在 asp.net 网页上有一个普通的 gridview...我想使用 jquery 选择一行,然后按一个按钮将 id 和 description 列发送到 Web 服务...

我的问题是如何选择行并获取我想要的信息...全部使用 jquery。

【问题讨论】:

    标签: jquery asp.net


    【解决方案1】:

    尝试类似的东西

    $('#<%=Grid.ClientID %>').delegate('tr', 'click', function(){
        $('#<%=Grid.ClientID %> tr').not(this).removeClass('selectedRow');
        $(this).toggleClass('selectedRow'); 
    });
    

    这应该使您能够在单击时选择单个 GridView 行。

    之后,对于按钮控件,使用以下

    $('#<%=Btn.ClientID %>').click(function(){
        alert($('#<%=Grid.ClientID %>').find('tr.selectedRow').html());
    
        // code to call the webservice using columns from $('#<%=Grid.ClientID %>').find('tr.selectedRow')
    
        // prevent Button control from causing a postback
        return false;
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-12
      • 1970-01-01
      • 2010-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-11
      • 1970-01-01
      相关资源
      最近更新 更多