Results 1 to 2 of 2

Thread: [RESOLVED] Template Column Textbox doesn't update text property when user types into it

  1. #1

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,902

    Resolved [RESOLVED] Template Column Textbox doesn't update text property when user types into it

    Hi All

    I've been staring at this for about the last hour and I'm sure I'm missing something obvious but I just can't see it. I have a DataGrid on a Web Form. It has a tempate column which is bound to a DataTable field called QtyUsed. This is initially populated with zeros and the intention is for the user to update the values and then click "confirm". The thing is, when I interrogate the .text property of the textbox it's showing zero, even though the user has changed the value.

    Here's the declaration of the column:-
    Code:
    <asp:TemplateColumn HeaderText="Used">
                                        <ItemTemplate>
                                            <asp:TextBox ID="QtyUsed" width="25px" MaxLength="3" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.QtyUsed") %>'></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateColumn>
    And here's me attempting to interrogate the text value:-
    Code:
    For Each item As DataGridItem In dgSpares.Items
                txtQtyUsed = item.FindControl("QtyUsed")
                txtQtyUsed = item.Cells(3).FindControl("QtyUsed")
                txtQtyUsed = item.Cells(3).Controls(1)
    Next
    As you can see I've tried it a few ways and I'm actually pretty sure they all work... in so far as they are returning the correct text box (I can check the other properties I've specified such as max length and they look correct) but the text property does not reflect any changes the user has made.

    Can anyone see what I'm doing wrong?


    edit> I wanted to make doubly sure that it was returning the right text box so I added a tooltip to it and can confirm 100% that it's the right text box. So the problem is that the text property is not being updated as a result of the user typing into it. Is there any reason that would be? I can't think of anything.
    Last edited by FunkyDexter; Feb 19th, 2013 at 07:39 AM.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  2. #2

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,902

    Re: Template Column Textbox doesn't update text property when user types into it

    [facepalm]
    OK, I'm an idiot.

    I was populating the grid in the page load event and was forgetting to check it wasn't a postback first. Thus I was just rewriting the zeros back over the user's values when the confirm buitton was pressed.

    I'm officially a dumb-ass. Move along please. Nothing to see here!
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

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