Question

When adding an EditItemTemplate of some complexity (mulitple fields in one template), and then parsing the controls from the RowUpdating event, the controls that were manually entered by the user have no values. My guess is there is something going on with when the data is bound, but I've had instances where simply adding and attribute to a control in codebehind started the behavior and removing that code made the code work. As a work-around, I can Request(controlname.UniqueId) to get it's value, but that is rather a hack.

Edit When I access the value like so

TextBox txtValue = gvwSettings.SelectedRow.FindControl("txtValue") as TextBox;

the text box is found, but the .Text is not the user input.

Was it helpful?

Solution

Did you turn off ViewState? Did you add control programmatically in the template? If so, did you create them at the correct stage?

OTHER TIPS

You should be able to use the GridViewUpdateEventArgs to retrieve the inputted value, for example:

TextBox txtValue = gvwSettings.SelectedRow.FindControl("txtValue") as TextBox;

I have used that syntax before and it works like a charm.

Moved post-back data-bind to Page_Init

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top