Results 1 to 12 of 12

Thread: [RESOLVED]textbox in GridView not getting new value

  1. #1

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Resolved [RESOLVED]textbox in GridView not getting new value

    using:
    -asp.net 2.0
    -Visual Studio 2005

    I have a gridview and one column has a textbox that can be edited in the gridview at all times. There is no Edit/Update/Delete columns here.

    From my business object (List) I'll bind it to the Grid.
    If I originally bind the value 3 to this textbox it displays correctly. When I change this 3 to another number, 5 for instance... and then use:

    Code:
    dim s as string =DirectCast(row.Cells(2).FindControl("QuantityTextBox"), TextBox).Text
    to get the new value of 5 and place it back into the List object
    the value is still 3 and not 5.
    I've used this method many times before and with no problems.
    I don't know why it isn't working here.
    This is driving me nuts. Any ideas?



    markup piece looks like this:

    Code:
     <asp:TemplateField HeaderText="Quantity">
                    <ItemTemplate >
                        <asp:TextBox ID="QuantityTextBox" runat="server" ></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
    Last edited by ZeBula8; Jul 30th, 2007 at 06:03 PM. Reason: [RESOLVED]

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: textbox in GridView not getting new value

    You've used a template field, and put a textbox in there. Good. When are you running that code to read from the textbox? What event?

  3. #3

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: textbox in GridView not getting new value

    [please ignore the mulitple duplicate posts - something with the server was stalling and my clicks ended up - moderator might want to look at the cause and effect of double-clicking the 'Submit post' button.)

    i should be able to run this code at any time to get the value from the textbox.



    Code:
    for each row as gridviewrow in gridview1.rows
      dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
    next

    I have done it this way in the past without a hitch...
    Last edited by ZeBula8; Jul 28th, 2007 at 10:13 PM.

  4. #4

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: textbox in GridView not getting new value

    i should be able to run this code at any time to get the value from the textbox.



    Code:
    for each row as gridviewrow in gridview1.rows
      dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
    next

    I have done it this way in the past without a hitch...

  5. #5

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: textbox in GridView not getting new value

    i should be able to run this code at any time to get the value from the textbox.



    Code:
    for each row as gridviewrow in gridview1.rows
      dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
    next

    I have done it this way in the past without a hitch...

  6. #6

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: textbox in GridView not getting new value

    i should be able to run this code at any time to get the value from the textbox.



    Code:
    for each row as gridviewrow in gridview1.rows
      dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
    next

    I have done it this way in the past without a hitch...

  7. #7

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: textbox in GridView not getting new value

    i should be able to run this code at any time to get the value from the textbox.



    Code:
    for each row as gridviewrow in gridview1.rows
      dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
    next

    I have done it this way in the past without a hitch...

  8. #8

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: textbox in GridView not getting new value

    i should be able to run this code at any time to get the value from the textbox.



    Code:
    for each row as gridviewrow in gridview1.rows
      dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
    next

    I have done it this way in the past without a hitch...

  9. #9

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: textbox in GridView not getting new value

    i should be able to run this code at any time to get the value from the textbox.



    Code:
    for each row as gridviewrow in gridview1.rows
      dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
    next

    I have done it this way in the past without a hitch...

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: textbox in GridView not getting new value

    Is the gridview being repopulated in the Page Load event without a postback check?

  11. #11

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: textbox in GridView not getting new value

    It was in fact that the gridview was being repopulated in the Page Load - thank you mendhak!

  12. #12
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED]textbox in GridView not getting new value

    Woohoo, I can read minds without reading code!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width