javascript - how to copy selected rows or records from Popup GridView to another in ASP.Net using checkboxes -
i following tutorial how copy selected rows or records 1 gridview in asp.net using checkboxes http://www.aspsnippets.com/articles/transfer-selected-rows-from-one-gridview-to-another-in-asp.net.aspx first gridbox follows:
<div id="dialog"> <asp:gridview id="gvitems" runat="server" autogeneratecolumns="false" datakeynames="sno" cellpadding="4" forecolor="#333333" gridlines="none" onpageindexchanging="onpageindexchanging" pagesize="5" allowpaging="true" onselectedindexchanged = "onselectedindexchanged"> <alternatingrowstyle backcolor="white" /> <columns> <asp:templatefield> <headertemplate> <asp:checkbox id="chkall" runat="server" autopostback = "true" oncheckedchanged = "checkbox_checkchanged"/> </headertemplate> <itemtemplate> <asp:checkbox id="chk" runat="server" autopostback = "true" oncheckedchanged = "checkbox_checkchanged" /> </itemtemplate> </asp:templatefield> <asp:buttonfield text="select" commandname="select" itemstyle-width="50"> <itemstyle width="50px"></itemstyle> </asp:buttonfield> <asp:boundfield datafield="sno" headertext="sno" /> <asp:boundfield datafield="itemcode" headertext="item code" itemstyle-width="50" > <itemstyle width="50px"></itemstyle> </asp:boundfield> </columns>
and have used 2 javascript functions check , check all follows:
function check_click(objref) { //get row based on checkbox var row = objref.parentnode.parentnode; //get reference of gridview var gridview = row.parentnode; //get input elements in gridview var inputlist = gridview.getelementsbytagname("input"); (var i=0;i<inputlist.length;i++) { //the first element header checkbox var headercheckbox = inputlist[0]; //based on or none checkboxes //are checked check/uncheck header checkbox var checked = true; if(inputlist[i].type == "checkbox" && inputlist[i] != headercheckbox) { if(!inputlist[i].checked) { checked = false; break; } } } headercheckbox.checked = checked; } function checkall(objref) { var gridview = objref.parentnode.parentnode.parentnode; var inputlist = gridview.getelementsbytagname("input"); (var i=0;i<inputlist.length;i++) { var row = inputlist[i].parentnode.parentnode; if(inputlist[i].type == "checkbox" && objref != inputlist[i]) { if (objref.checked) { inputlist[i].checked=true; } else { if(row.rowindex % 2 == 0) { row.style.backgroundcolor = "#c2d69b"; } else { row.style.backgroundcolor = "white"; } inputlist[i].checked=false; } } } } //--> </script>
it working fine. need change first gridview popup gridview .so, have used javascript functions show popup folllows:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script> <link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $(function () { $("[id*=btnshowpopup]").click(function () { showpopup(); return false; }); }); function showpopup() { $("#dialog").dialog({ title: "gridview", width: 550, buttons: { ok: function () { $(this).dialog('close'); } }, modal: true }); } </script>
it makes gridview popup.but,i can not value when clicking checkbox. want check multiple checkboxes , transfer multiple rows without postback.please guide me how can use ajax.thank you
Comments
Post a Comment