Solved

Call the TextChange event for a textbox inside a datagrid.

Posted on 2006-07-15
5
1,855 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
ID: 17114994
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
ID: 17115722
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
ID: 17116554
i'm agree with Ramuncikas, it better than you use java script rather than postback and its problems
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
convert html to string 6 34
Delete HTML table rows 12 28
Executing SSIS with a Stored Procedure Permissions 12 61
jquery progress bar 3 41
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…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 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