How to get the particular cell value from a gridview and to display it in a textbox using jquery in asp.net?

Course Queries Syllabus Queries 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

The following is my grid view code. In this, I have one column "Syllabus". In the next column I'm having edit and delete buttons. On clicking the Edit button, a popup will display. I displayed that popup using jquery. In the popup, I'm having a textbox for Syllabus. But I dont know how to get that syllabus value from the gridview column and to display its value in the popup for editing its value?

 <asp:GridView ID="gdvwSyllabus" CssClass="enquiryTable" runat="server" AutoGenerateColumns="false" Width="100%">
            <Columns>
                <asp:BoundField HeaderText ="Syllabus" DataField ="Syllabus" />
                <asp:TemplateField HeaderText="Options">
                    <ItemTemplate>
                        <ul class="enquiryList1">
                           
  • <a href="#"><asp:Image ImageUrl="~/Images/edit2.png" runat="server" ID="btnSyllabusEdit" CssClass="btnEdit" />a>li>
  • <asp:Image ImageUrl="~/Images/delete2.png" runat="server" ID="btnDelete" />a>li> ul> ItemTemplate> asp:TemplateField> Columns> asp:GridView>
  • This is my popup code which I designed it as a table.This table will popup on clicking the edit button.I want to display the "syllabus" value in the "txtsyllabus" textbox for edit.

     <table style="border: 0px; margin-left: 15px;" border="0" align="left">
                    
                        <td align="right">Syllabus <span class="ErrorField">*span>:td>
                        
                            <asp:TextBox ID="txtsyllabus" CssClass="txtbox txtSyllabus" runat="server">asp:TextBox>
    
                        td>
                    tr>
                     
                          &nbsp;td>
                          <td align="left">
                             <a href="#"><asp:Button ID="btnSubmit" Text="Save" CssClass="btnStyle btnSyllabusSubmit" runat="server" />a>
                          td>
                     tr>
                table>

    Thanks in advance.

    profilepic.png
    manpreet 2 years ago

    You can do this by calling a javascript function from button on client click as following:

    function showpopup(details)
    {
    document.getElementById('texbox').value=details
    document.getElementById('divpopup').style.display='block'

    return false; }

    on gridview item databound event do the code like this

    btn=e.item.findcontrol("editbouttn")
    btn.attributes.add("onclick","return showpopup(" & e.item.dataitem("details") & ");"

    please let me know if this does not work.


    0 views   0 shares

    No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.