1

i have gridview with following itemtemplate

<ItemTemplate>
 <asp:TextBox ID="txtComments" runat="server" Text='<%# Bind("Comments") %>'
 </asp:TextBox>

<asp:LinkButton href="#modal-dialog1" ID="href_Score" role="button" data-toggle="modal"
runat="server" class="icon-photon comment_alt2_stroke" OnClientClick='<%# string.Format("javascript:return GetScores(this,\"{0}\")", Eval("ExceptionID")) %>'>
</asp:LinkButton>

</ItemTemplate>

one text box is there inside gridview and one link button also to popup the text box data.I am able to pop up the data.

In pop up window i am having another text box ,once data filled to this text box on clicking click me button of popup window, i need to assign pop up text box values back to the gridview text box.

Here is my popup div(which is created using javascript function)

<div id="modal-dialog1" class="modal hide fade">
                <div class="modal-header">
                    <button type="button" id="btnCloseModal" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h3>Score Detail</h3>
                    <br />                    
                    <span style="color: #4F81BD">
                        <br />
                        * Use as a finding ONLY .</span>
                </div>

                <div class="modal-body">
                    <h4>Scores</h4>
                    <input type="text" name="AddComments" value=""/>
                    <button onclick="return myFunction()">Click me</button> 
                    <hr />                                              
                </div>
            </div>

i want to set the text box value back to the gridview inside myFunction() function pls help me? how can i set values to gridview inside javascript function?

9
  • Post your javascript code Commented Dec 12, 2015 at 10:00
  • @Satindersingh i don't tried anything inside myFunction() ,not having any idea to set values to gridview through javascript\jquery Commented Dec 12, 2015 at 18:49
  • Can you share the code to open the popup? Commented Dec 13, 2015 at 10:44
  • @Rahul Singh: hi, i am just caliing a webmethod(which executes an stored proc) which will return above mentioned html popoup Commented Dec 13, 2015 at 10:48
  • @Athul - Okay so are you using Bootstrap in your project? Commented Dec 13, 2015 at 10:49

1 Answer 1

1

You can use the jQuery on method to bind the button click event handler and populate the textbox present inside the gridview like this:-

 $("#div_History").on('click','button.btn', function (e) {
       e.preventDefault();
       var firstRow = $('tr:nth-child(2)', $('#GridView1'));
       var outsideText = $('#txtOutside').val();
       $('#txtfoo', firstRow).val(outsideText);
 });

For safer side I have added a class to the button control. You can change it like this:-

<button onclick="return myFunction()" class="btn btn-primary">Click me</button> 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.