Pages

Friday 16 September 2011

get the selected gridview row value using jquery

 <style type="text/css">
        .highlite
        {
            background-color: Gray;
        }
    </style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
    </script>
 <script type="text/javascript">
        $(function () {
            $(".gv > tbody > tr:not(:has(table, th))")
                .css("cursor", "pointer")
                .click(function (e) {
                    $(".gv td").removeClass("highlite");
                    var $cell = $(e.target).closest("tr");
                    $cell.addClass('highlite');
                    var $currentCellText = $cell[0];
                    var $2= $currentCellText.cells[0].innerHTML;
                    var $3= $currentCellText.cells[1].innerHTML;
                    var $4= $currentCellText.cells[2].innerHTML;
                    $("#HiddenField1").val($2);
                    $("#HiddenField2").val($3);
                    $("#HiddenField3").val($4);
                    alert($("#HiddenField1").val());
                    alert($("#HiddenField2").val());
                    alert($("#HiddenField3").val());
                });
        });
    </script>
<asp:gridview class="gv"/>

No comments:

Post a Comment