I have a situation where I need to work with a datagrid and adding columns dynamically in PageInit as the grid has a few conditional requests that it must handle. I'm moving along easily with BoundColumns, and ButtonColumns, those are easy. The problem is with the creation of a TemplateColumn via code. I have found examples out there about creating a custom class that add controls dynamically by creating a class that uses an implementation of ITemplate. That works, however, I'm struggling with how to databind elements.
In my grid I would have used <%= DataBinder.Eval(Container.DataItem, "MyValue") %> or similar, but that isn't an option here. The Container when inside ITemplate doesn't have a data item property either, so I can't bind there. Anyone have advice or links that might help, I'm just not finding the right things in google.