Editable TextBox without Edit Mode in Gridview

Discussion in '.NET' started by mbonney, Sep 10, 2008.

  1. mbonney

    mbonney

    Joined:
    Sep 10, 2008
    Messages:
    1
    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
    mbonney, Sep 10, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. savajx1
    Replies:
    1
    Views:
    1,794
    savajx1
    May 6, 2007
  2. anonymoushamster
    Replies:
    4
    Views:
    356
    hamsterchaos@gmail.com
    Nov 13, 2007
  3. Cahoo
    Replies:
    4
    Views:
    249
    Scott M.
    Aug 30, 2004
  4. Jaime Stuardo

    GridView control enters edit mode when I click Edit link twice

    Jaime Stuardo, Apr 7, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    394
    Jaime Stuardo
    Apr 7, 2006
  5. qa4ever
    Replies:
    3
    Views:
    241
Loading...

Share This Page