DataGrid Edit Problem
-
I have a DataGrid which I have bound to an arraylist with some data in, and everyone is happy... When I click on Edit, I get TextBoxes in the grid, just as expected, but when I click Update and use the following code:
TextBox description = (TextBox)e.Item.Cells[0].Controls[0];
thedescription
textbox always holds the original value, not the one I wrote before hitting Update... :confused: Any ideas? - Anders My PhotosWDevs - The worlds first DSP, free blog space, email and more
-
I have a DataGrid which I have bound to an arraylist with some data in, and everyone is happy... When I click on Edit, I get TextBoxes in the grid, just as expected, but when I click Update and use the following code:
TextBox description = (TextBox)e.Item.Cells[0].Controls[0];
thedescription
textbox always holds the original value, not the one I wrote before hitting Update... :confused: Any ideas? - Anders My PhotosWDevs - The worlds first DSP, free blog space, email and more
Anders, When you click the update button, the datagrid is probably databinding in the page load event. Therefor, the changed value is being changed back to the original value when it databinds. If this is the case, you need to test for Page.IsPostback and if it is not a postback (meaning first page load instead of a postback), then you bind the datagrid. I hope I have made sense. If not, let me know and I can explain further. I am typing with one hand, so hopefully, I do not have too many typos. Jeremy Oldham
-
Anders, When you click the update button, the datagrid is probably databinding in the page load event. Therefor, the changed value is being changed back to the original value when it databinds. If this is the case, you need to test for Page.IsPostback and if it is not a postback (meaning first page load instead of a postback), then you bind the datagrid. I hope I have made sense. If not, let me know and I can explain further. I am typing with one hand, so hopefully, I do not have too many typos. Jeremy Oldham
Jeremy, What you say makes perfectly sense. It was not exactly what caused it, but almost... Doh, stupid me :-O Thanks... - Anders My Photos
WDevs - The worlds first DSP, free blog space, email and more