tags:

views:

105

answers:

1

Hi, I have asp.net's .aspx page. that have GridView let say GridViewParent and Each row have the another GridView as GridViewChild. Now GridViewChild have button AddRow and another controls like DropDownControl,RadioButtons..etc... I want after click the button AddRow there must add row on client side. How can i do same. Please guide me .... Send me code

A: 
<script type="text/javascript" src="../../js/jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
    $('#<%=cmdAdd.ClientID %>').bind('click', function(event) {
        //debugger;
        event.preventDefault();
        var $grid = $('#<%=ctlGrid.ClientID %> ');
        var $row = $grid.find('tr:last').clone().appendTo($grid);
        $row.find('select')[0].selectedIndex = 0;
        $row.find('input').each(function() {
            $(this).val("");
        });
        return true;
    });
});

epitka
Good logic used here....
Lalit
You will run into problems though if you postback the page because of event validation. Also, code above just clones the row, you need to change ids. All in all, either use jQuery and do everything via ajax, or just give up and use UpdatePanel.
epitka