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 3 years ago

3.57K 2 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 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.

    0 views
    0 shares

    profilepic.png
    manpreet 3 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.

    Similar Forum