通过Gridview迭代 [英] Iterate through Gridview

查看:80
本文介绍了通过Gridview迭代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到gridview的情况 -



**情景** 一旦有人点击删除,它会得到NOtif_recip_Id行并迭代Gridview以查看对应于该NOTIF_RECIP_ID的任何行的NOTIF_RECIP_SEQ_NBR是否更大。



我已编写代码但我不认为这是一个好的way.Can有人告诉任何更好的方法来做这件事。

I have a situation with gridview -

**Scenario** once someone click on delete,it gets the NOtif_recip_Id of that row and iterates through Gridview to see if NOTIF_RECIP_SEQ_NBR of any row corresponding to that NOTIF_RECIP_ID is greater or not.

I have written the code but I dont think this is a good way.Can someone tell any better way to do this.

<script type = "text/javascript">
        function GetSelectedRow(lnk) {
        debugger;
          var table, tbody, i, rowLen, row, j, colLen, cell;

            var result = confirm('Do you want to delete this value ?');
            if (result) {

                var x = document.getElementById('Label100');


                table = document.getElementById("GridView1");
                tbody = table.tBodies[0];

                var bool = true;
                var row = lnk.parentNode.parentNode;
                var rowIndex = row.rowIndex - 1;

                var RecipID = row.cells[0].innerText;
                var Sqqno = parseInt(row.cells[1].innerText);

                for (i = 1, rowLen = tbody.rows.length; i < rowLen; i++) {
                    row = tbody.rows[i];

                    var newrecipId = row.cells[0].innerText;
                    if (newrecipId == RecipID) {
                        cell = row.cells[1];

                        var newseq = parseInt(row.cells[1].innerText);
                        if (Sqqno < newseq) {
                            // debugger;
                            bool = false;
                            x = document.getElementById('Label100');
                            x.innerHTML = "ERROR-Delete RecipId with max Seqnumber";
                            x.style.display = "block";

                            return bool;
                            break;
                        }

                    }
                    else {
                        bool = true;
                    }

                }

                return bool;
            }
            else {
                return false;
            }

        }
    </script>





linkbutton的代码如下:





And the code for linkbutton is as follows:

<asp:LinkButton ID="lnkSelect" runat="server" Text="Delete" CommandName = "Select"

         OnClientClick = "return GetSelectedRow(this)"  CommandArgument = '<%# Eval("NOTIF_RECIP_GUID")%>'  OnClick = "DeleteRecipdata" />

推荐答案





你可以试试,



Hi,

You can try like,

function GetSelectedRows() {


#GridView1 tr )。each(function(){

var textBox =
("#GridView1 tr").each(function () { var textBox =


this )。find( input [type ='text ]);
// 您的代码在此检查
}
} );
}
(this).find("input[type='text']"); //your code in here to check } }); }







希望这会有所帮助。




Hope this helps.


这篇关于通过Gridview迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆