Hi
I have attached image . Using Gridview. I want when in any row under colum Hritvi is clicked i want to get its Mobile No.
Similarly when in any row under colum Srini is clicked i want Srini Mobile no without PostBack
Thanks
Hi
I have attached image . Using Gridview. I want when in any row under colum Hritvi is clicked i want to get its Mobile No.
Similarly when in any row under colum Srini is clicked i want Srini Mobile no without PostBack
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mohamed Azarudeen ZRank #297 · 8.5K reputationPosted May 10, 2023, 1:34 PM EDT
, you can use JavaScript and add an event listener to the column headers for "Hritvi" and "Srini". When the headers are clicked, you can use the DOM traversal methods to find the corresponding cell in the same row and retrieve the mobile number from it.
// add event listeners to the column headers document.querySelector('th:nth-child(3)').addEventListener('click', handleHritviClick); document.querySelector('th:nth-child(4)').addEventListener('click', handleSriniClick); function handleHritviClick(event) { // get the index of the Hritvi column const columnIndex = Array.from(event.target.parentNode.children).indexOf(event.target); // get the mobile number from the corresponding cell in the same row const mobileNumber = event.target.parentNode.nextElementSibling.children[columnIndex].textContent; console.log('Hritvi mobile number:', mobileNumber); } function handleSriniClick(event) { // get the index of the Srini column const columnIndex = Array.from(event.target.parentNode.children).indexOf(event.target); // get the mobile number from the corresponding cell in the same row const mobileNumber = event.target.parentNode.nextElementSibling.children[columnIndex].textContent; console.log('Srini mobile number:', mobileNumber); }provide your code if this doesnt work