Textbox in autogenerated-Gridview
I am facing a difficult problem at the moment. I am about to make single columns of a GridView Control editable.
- the GridView is bound to a DataTable, which receives its content from a few database queries
- the columns of the gridview are generated automatically
- by clicking on a column name I use the GridView.Sorting event to add TextBox Controls to the column I just clicked (this works already)
- after the editing work, a button is clicked which should bind the changed values to the initial DataTable.
And this won't work ... and here is what happens:
After clicking the Store-Button, all my Textboxes are immediately deleted from my GridView, I am not able to save the changed values anyhow.
The picture below shows how the grid looks in edit-mode:
http://img78.imageshack.us/img78/603/grideditmodedh3.jpg
I already had a few thoughts about my problem, maybe you know better.
- Is it possible to keep controls like my TextBoxes in a databound Gridview with autogenerated columns after e.g. clicking a button or doing a PostBack?
- Is there a possibility to have the columns of my datatable in design-mode too (which would make it easy to convert the auto-fields into template-fields)?
- The TextBox controls are deleted from my GridViewCells immediately after clicking any button. Is there an event in which I could still get the values from these controls?
- Could this whole problem have something to do with my GridView rebinding data when doing a PostBack of being some kind of ReadOnly (the GridView.Columns.ReadOnly-property is set to FALSE by the way)?
- What would be the quickest method to convert my autogenerated-columns into templated columns? Do you have any further suggestions to solve my problem?
Best regards,
David

