Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 2nd, 2003, 09:49 AM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Textbox not updating

Hi,

I've created a simple shopping cart web app, and I'm using a Data Grid to display the shopping cart table. I inserted a textbox into a TemplateColumn, and in the code behind page, I use:
TextBox txtQuantity = (TextBox) DataGrid1.Items[i].FindControl("Quantity") to grab the value from each row. I then compare txtQuantity to DataGrid1.DataKeys[i] (the Quantity datafield is assigned as the DataFieldKey). But if the Quantity textbox is updated, the old one that was pulled from the database is still the value -- it's not reading my change. Any ideas? Thank you in advance.
__________________
Steve
iTek Corporation
http://itekcorp.com
 
Old October 2nd, 2003, 10:11 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

How are you binding the data to the grid? Are you binding only once per page lifecycle/data operation? You should bind to the grid once when the page is loaded:
If Not IsPostback Then
    BindDataGrid()
End If

Then any time you make a change to the data (update records, add new records, etc). Otherwise, you are rebuilding the datagrid from data every time you load the page and your posted changed (those in the text boxes) are getting ignored.

Why are you using a template column with a textbox versus a bound column?

Peter
 
Old October 2nd, 2003, 10:20 AM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you -- that did it! One of those "I can't believe I missed that" moments! I really appreciate it. I'm using a textbox because I want users to be able to update the quantity. Thanks again.
 
Old October 2nd, 2003, 01:07 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The BoundColumn puts a textbox in place of a value when the row is being edited. Sounds like you want ALL the rows to have that column editable without having to actually use an editcommand. That makes sense.

Peter
 
Old January 16th, 2005, 11:07 PM
Registered User
 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to AleBernardi Send a message via MSN to AleBernardi
Default

I've had an analog problem:

Any time I try to update my datagrid I get the same old values.

The reason is because I forgot the event sequence in my page:
In my Page_Load function I was binding the dataset to the datagrid, and this is the first event trapped after the update command click.
When it is trapped the other event it was too late, because the data was already binded with old values.

I just put a PostBack check, not to bind data when IsPostBack and I solved the problem.

I hope it could be helpful for you too,
bye,
Ale.

Alessandro Bernardi
BBros snc





Similar Threads
Thread Thread Starter Forum Replies Last Post
pointing cursor from one textbox to other textbox lakshmi_annayappa ASP.NET 1.0 and 1.1 Basics 2 August 2nd, 2007 03:41 PM
Combo box updating textbox needelp Access VBA 1 January 12th, 2007 12:26 PM
Updating a textbox from DropDown selection kjord ASP.NET 1.0 and 1.1 Professional 4 November 7th, 2006 04:04 AM
Masked TextBox & formatting TextBox melvik C# 1 September 22nd, 2003 11:01 AM
Updating dmurray Access 1 June 25th, 2003 05:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.