I haven't worked with GridView too much and after poking around with it, find it to be more complex than I need but missing some very basic abilities that I would expect it to have. No doubt its implementation makes sense given its 90% of the time purpose of being bound to a dataset especially when doing this declaratively, but I intend to bind it to an IEnumerable<T>
in code.
What I need is the ability to do the following easily
- a) be bound to an
IEnumerable<T>
where the columns can be limited to only certain properties of typeT
- b) be queried to return a collection of its rows where each row can have a cell looked up by the property that cell was bound to
basically something implementing the following interface would be nice
public interface IEasyGridBinder {
void Bind<T>(IEnumerable<T> bindableObjects, params string[] propertiesToBind);
IList<IDictionary<string, string>> Values {get;}
}
So to get this, should I write my own custom EasyGridBinder that inherits from GridView and implements this interface or is there a really simple way to do these things that I am just unfamiliar with?
P.S. Bonus points if I can write something like
myGrid.Bind(myEntities, e=>{e.Id; e.Name; e.Customer.Name;});
But I suppose I can figure that out myself after reading up on expressions
Follow-up question: Is there no way to get the original data that was input into the gridview and has not been converted to html? If a field received as input an empty string the cell seems to contain " " so is there no way to distinguish between an input of an empty string and a space? If this is indeed the case then I probably WILL end up re-implementing most of GridView's functionality.