Don’t Fight the .Net GridView
Friday, 2 June 2006
The .Net GridView prefers to work through DataSources. I tried to use old style Fill dataset, then DataBind() and it simply doesn’t play well with Editing.
In addition, the ObjectDataSource.DataObjectTypeName is riculously underpowered. This version doesn’t get types of inner classes. It uses System.Web.Compilation.BuildManager.GetType instead of System.Type.GetType.
System.Type.GetType("MyStronglyTypedDataSet.MyTableRow"); // works
System.Web.Compilation.BuildManager.GetType("MyStronglyTypedDataSet.MyTableRow", true); // fails
Update 1 : Inner class notation is required:
System.Web.Compilation.BuildManager.GetType("MyStronglyTypedDataSet+MyTableRow", true); // fails
Update 2 : You still can’t use DataObjectTypeName
Turns out the MyStronglyTypedDataSet+MyTableRow doesn’t have a parameterless constructor.
Suddenly code generation without magic seems much more palatable.