Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to Print Asp.net GridView Data on Button Click using Javascript?

Answer Posted / Jai Singh Yadav

To print ASP.NET GridView data on button click using JavaScript, you can use the following approach: first, assign ID to your GridView and Button controls; next, write a JavaScript function that will iterate through rows of the GridView, get cells' values, and concatenate them into a string; finally, call this function when the button is clicked.nnHere is an example:nn```htmln<asp:GridView ID="gvData" runat="server" ... />n<asp:Button ID="btnPrint" runat="server" OnClick="btnPrint_Click" Text="Print Data" />n<script>nfunction printGrid() {n var table = document.getElementById("<%= gvData.ClientID %> ");n var str = &quot;n";n for (var i = 1; i < table.rows.length; i++) {n var row = table.rows[i];n for (var j = 0; j < row.cells.length; j++) {n str += row.cells[j].innerText + &quot;t&quot;;n }n str += &quot;n";n }n window.print();n}nfunction btnPrint_Click(sender, args) {n printGrid();n}n</script>n```

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category