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
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