?
Solved

Call the TextChange event for a textbox inside a datagrid.

Posted on 2006-07-15
5
Medium Priority
?
1,860 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 14

Accepted Solution

by:
Ramuncikas earned 336 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 332 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 332 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

765 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