How can the width of an edit text box be set in a GridView control where EnableSortingAndPagingCallback is true? Microsoft's documentation for GridView.EnableSortingandPagingCallbacks states "If the Columns collection contains a column that does not support callbacks, such as TemplateField, a NotSupportedException exception is raised." So this rules out the use of a template column. I tried the template column and found it caused an error as advertised. I posted this question on Express Exchange but received only one bogus response.
Here is my GridView code...
After much searching of the internet, and only one bogus response from "Experts Exchange" I set to work my to solve the problem myself. Here is my work around...
- Create a integer variable, editRow, and set its value to -2
- When the OnEditRowEditing event fires, set editRow to the value of the selected row index.
- As the ViewGrid re-builds, check for the row selected for editing. When found, check the specific cell for an empty string. If the cell contains a text box control the cell Text value will be "".
- Next cast the cell's first control to a TextBox then you can set its various properties including it's width.