Solved

Call the TextChange event for a textbox inside a datagrid.

Posted on 2006-07-15
5
1,850 Views
Last Modified: 2008-01-09
Hi,
I have a ASP.net 1.1 Webform that contains a datagrid , that contains 4 columns
Product--Qty--Price--Total

Each column has a textbox. The user will enter a value in the Product and the Qty and Price textbox. I want to call the TextChange event of the Qty and Price and textboxes whenever the text inside them changes.
In the called textchange event I want to calculate the expression Qty*Price and assign the result to the Total textbox in the datagrid.

How can I do this?

Note:The controls are in the Datagrid.
0
Comment
Question by:TetraSA
5 Comments
 
LVL 14

Accepted Solution

by:
Ramuncikas earned 84 total points
Comment Utility
TextChange event occures only when user inputs text into textbox AND hits enter key. But this way page-post-back occures. If user moves focus to another control with a mouse or TAB key, TextChange event will occur only after next postback. And I think it is not what you want.
I think that the best choise here is javascript. You should assign javascript junction to a string variable and register this function with Page.RegisterStartupScript. Next, whenever you add textboxes to datagrid, you should add this function as textbox's onleave (I guess) attribute to appropriate textboxes.
One problem you'll meet here is textboxes' names (or IDs in javascript). Even if you assign unique names to textboxes in datagrid's template columns they are chaned during page render. This happens so to keep unique names in a whole datagrid.
But I think this can be solved.
Here is what I can suggest you from a ASP.NET side. Javasript is not my strong side so I can suggest you wait for someone to respond with answer how to build javascript function (or even more better solution) that I was talking about or post a pointer question in javascript TA.
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 83 total points
Comment Utility
You can define a DataColumn in the DataTable that has Qty * Price for the expression.

Bob
0
 
LVL 9

Assisted Solution

by:zaghaghi
zaghaghi earned 83 total points
Comment Utility
i'm agree with Ramuncikas, it better than you use java script rather than postback and its problems
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now