Solved

Call the TextChange event for a textbox inside a datagrid.

Posted on 2006-07-15
5
1,858 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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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