Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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)
Posted

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



Thanks
Sanju Nambiar
 
Share this answer
 
v2
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:

XML
<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 Method:

<pre lang="cs">function NoCommaAllowed(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode
return !(charCode == 44);
}</pre>
 
Share this answer
 
Kindly go though this link hope your requirements will fulfilled

http://stackoverflow.com/questions/6341856/keypress-event-for-textbox-which-is-in-gridview[^]
 
Share this answer
 
Comments
Thanks7872 2-Jun-14 7:47am    
So you are expecting us to write 100% code for you right?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900