如何处理网格视图中存在的文本框的按键事件 [英] how to handle on key press event of a textbox present inside a grid view

查看:97
本文介绍了如何处理网格视图中存在的文本框的按键事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,



我有一个名为grditemDetails的网格视图

,因为有3个文本框,即txtItemQty,txtItemPrice,txtItemAmmount
如果用户在txtItemQty字段中输入任何内容,将填写选择商品价格列的


自动填写txtItemAmmount而不使用 textchanged 事件



有什么办法吗?



提前付款

(Keerthi Kumar)

Hi experts,

I have one grid view called grditemDetails
in that there are 3 text boxes namely txtItemQty,txtItemPrice,txtItemAmmount
on selecting a item price column will be filled if user entered anything inside txtItemQty field
automatically txtItemAmmount should be filled without using textchanged event

is there any way to do this??

thanks in advance
(Keerthi Kumar)

推荐答案

在模板字段内添加文本框写入

Add textbox inside template field write
<asp:textbox id="txt1" onkeypress="return changeColoronfocus(this);" xmlns:asp="#unknown"></asp:textbox> 







谢谢

Sanju Nambiar




Thanks
Sanju Nambiar


以下是调用a的示例处理按键事件的JavaScript方法。我还包括下面的JavaScript方法。



GridView专栏内:



Here is example of calling a JavaScript method that handles key press event. I also included the JavaScript method, below.

Inside of the GridView column:

<asp:TemplateField HeaderText="Doses Received" FooterStyle-Width="70px" HeaderStyle-Wrap="true" ItemStyle-Width="70px">
                                            <ItemTemplate>
                                                <asp:TextBox ID="txtDosesReceived" runat="server" onkeypress="return NoCommaAllowed(event);" MaxLength="10" Width="70px"

                                                    Text='<%# Bind("DosesReceived") %>'></asp:TextBox>
                                            </ItemTemplate>
                                            <HeaderStyle HorizontalAlign="Center" />
                                        </asp:TemplateField>





JS方法:



< pre lang =cs>函数NoCommaAllowed(evt){

var charCode =(evt.which)? evt.which:event.keyCode

return!(charCode == 44);

}< / pre>



JS Method:

<pre lang="cs">function NoCommaAllowed(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode
return !(charCode == 44);
}</pre>


亲切虽然这个链接希望你的要求能够实现



http://stackoverflow.com/questions/6341856/keypress-event-for-textbox-which-is-in-gridview [ ^ ]
Kindly go though this link hope your requirements will fulfilled

http://stackoverflow.com/questions/6341856/keypress-event-for-textbox-which-is-in-gridview[^]


这篇关于如何处理网格视图中存在的文本框的按键事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆