TextBox in Gridview retaining old value
-
I am making an editable Gridview and it gets filled with data. When I click my Edit button I have some textboxes that are populated with the "old" data. I type in "new" different data. I have a line of code like this: TextBox txtUpdateHours = (TextBox)gvwDetails.Rows[e.RowIndex].FindControl("txtHours"); string newHours = txtUpdateHours.Text; However the newHours variable is always the "old" value, not what I just typed in. How can I get the "new" value? I know it must be simple but I am trouble finding what I need. Thanks for any help.
-
I am making an editable Gridview and it gets filled with data. When I click my Edit button I have some textboxes that are populated with the "old" data. I type in "new" different data. I have a line of code like this: TextBox txtUpdateHours = (TextBox)gvwDetails.Rows[e.RowIndex].FindControl("txtHours"); string newHours = txtUpdateHours.Text; However the newHours variable is always the "old" value, not what I just typed in. How can I get the "new" value? I know it must be simple but I am trouble finding what I need. Thanks for any help.
rebind your grid data source after updating.
Padmanabhan
-
rebind your grid data source after updating.
Padmanabhan
Thank you for the response. I'm not sure this will help my problem because it seems to be occuring *before* the update...I set breakpoints on the Update function and I can see it is updating with the original values, not what I just typed in the textbox. No matter what I type in the textbox it retains the original values from the data source and I'd like the Update to use what I just typed in. I'm not sure why it's doing this.
-
Thank you for the response. I'm not sure this will help my problem because it seems to be occuring *before* the update...I set breakpoints on the Update function and I can see it is updating with the original values, not what I just typed in the textbox. No matter what I type in the textbox it retains the original values from the data source and I'd like the Update to use what I just typed in. I'm not sure why it's doing this.
is your code placed within if (!Page.IsPostback) ?
In Word you can only store 2 bytes. That is why I use Writer.
-
is your code placed within if (!Page.IsPostback) ?
In Word you can only store 2 bytes. That is why I use Writer.
:doh: Yes that was it, thanks so much.