如何从javascript函数设置值gridview的文本框 [英] How to set values to gridview textbox from javascript function
问题描述
我有以下的GridView的ItemTemplate
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>
一个文本框里面有GridView和一个连接按钮也会弹出的文本框中data.I我能弹出数据。
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.
在弹出的窗口我有另一个文本框,一旦数据填充到该文本框上单击单击我的弹出窗口的按钮,我需要分配弹出文本框值回gridview的文本框。
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.
下面是我的弹出格(这是使用JavaScript函数创建)
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">×</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>
我要设置文本框的值返回到GridView里面myFunction的()函数请帮帮我吗?如何设置值JavaScript函数里面的GridView?
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?
推荐答案
您可以使用的的jQuery 的上绑定按钮单击事件处理程序和填充gridview的喜欢里面的文本框present方法这样的: -
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>
这篇关于如何从javascript函数设置值gridview的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!