ASP.NET 2.0 BasicsIf you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
How to change the value of one cell in a GridView?
===========default2.apsx source file =====
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Inside the RowCreated event (which fires for each row added to the GridView) you can use FindControl to get a reference to your TextBox controls. Then you can ask for its ClientID which is the HTML id attribute as it ends up in the browser.
Then on one textbox you can add a client side onblur event to calculate whatever it is you need to calculate. This onblur handler should get the references to the TextBoxes whose ClientID you retrieved in the RowCreated event.
Finally, you can add the onblur event to the TextBox using its Attributes collection.
The goal is GridView1 retrieves 2 values OrderID, UnitPrice from a look-up table tblLookUp. The Users can change the value in the Quantity field of the added Template TextBox, SubTotal will change to Quantity * UnitPrce.
Then, user can save the set of GridView1 records to another table tblFinal.