Editable TextBox without Edit Mode in Gridview

Joined
Sep 10, 2008
Messages
1
Reaction score
0
I'm trying to create a GridView on my web page that has a textbox in each row. The textbox is in an item template. The textbox is there to allow the user to enter a quantity. When the user clicks on a button I want to be able to retrieve the quantity in each textbox. I'm able to access the textbox control in each row but when I retrieve the text of the textbox it is not the value the user entered but the initial value that I assigned to the textbox. I don't want to use edit mode because I don't want the user to have to click a link then enter the quantity then end edit mode. Also I don't want to do it this way because I want the user to be able to change the value if needed before clicking on the button. Below is the code I'm using to try to retrieve the values.

string myCode = "";

// Look at each row and determine if the row contains a quantity value.
foreach (GridViewRow rows in ProductGV.Rows)
{
if (rows.FindControl("TxtQty") != null)
{
// Get the quantity.
Int32 quantity = 0;
bool result = Int32.TryParse((((TextBox)(rows.FindControl("TxtQty"))).Text), out quantity);
if (result && quantity > 0)
{
// perform action with quantity
}
}
}

Thanks,
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top