Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

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

$
0
0
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.

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>