ASP.NET 2 Textbox value in Gridview row
I have written a page whose content includes a gridview. This gridview will display the shopping cart of my web app. I have set the columns and one column is a template field set as follows:
<asp:TextBox runat="server" id="txtChangeQuantity" text='<%# Eval("Quantity") %>'>
The gridview is bound to the "cart" DataTable (included in the Profile in web.config)
I want to accomplish the following: When the user changes the quantity in the "txtChangeQuantity" textbox of a row and clicks on a button next to it (the next cell), the Profile cart gets updated with the new quantity. However, even though I have tried many ways to get the NEW value that the user types in the quantity text box, I always get either an empty string or the databound original value. I bind the gridview in the Page_Load method checking that it is not a postback i.e. "if not page.ispostback then BIND GRIDVIEW".
I have tried to get hold of the user typed value in various code-behind methods (e.g. rowupdating), using the following generic syntax:
dim tx as string = CType(e.row(index).FindControl("txtChangeQuantity"),textbox).Text or even CType(e.row(index).Cells(4).FindControl("txtChangeQuantity"),textbox).Text
Now I am starting to wonder if this type of functionality is possible if the gridview is not set as EDITABLE (i.e. with the "Edit" and "Update" buttons).
If it is possible to set the 'txtChangeQuantity' text box as editable and I can get hold of the newly typed value (after a button click in the same row or other method), I would greatly appreciate any help in knowing the method!! Or maybe what I should add/remove in the gridview code....
Thanks very much in advance,
By seasider in forum ASP.NET
Last Post: 12-03-2008, 04:03 PM
By Rathi in forum ASP.NET
Last Post: 05-12-2006, 01:03 AM
By clean in forum ASP.NET
Last Post: 02-13-2006, 03:56 PM
By mycwcgr in forum ASP.NET
Last Post: 10-11-2005, 09:12 AM
By ASPSmith Training in forum dotnet.announcements
Last Post: 06-18-2002, 04:39 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center