title: Make Gridview interact with something other than properties
body: <p>We're planning to create a web application where users can build custom "forms," choosing which fields they would like, and how the data in those fields should be represented.  Users can then fill out these forms in a DetailsView-like control, thereby creating "documents."  The documents can be shown in a DetailsView, or certain fields of several of them can be shown in a GridView.  At least, that's the idea.</p>
  
  <p>The problem is that GridView and DetailsView seem to be specifically designed to access Properties on objects that come out of a DataSource.  Since we want to have completely arbitrary forms, we can't restrict ourselves to building a class with Properties to represent each field.  We have to be able to have any number of dynamically-specified fields on a form.</p>
  
  <p>Is there any way to leverage the existing controls so we don't have to re-implement paging, sorting, and all the other things that GridViews are already set up to do, or will I just have to create my own GridView-like control from scratch?</p>
  
  <h2>Edit:</h2>
  
  <p>More specifically, the difficulty I am having is in getting inline editing to work on the GridView.  For example, let's say that one of the "fields" that is added to a "form" is a calendar field, which should display a date as text in read-only mode, and display a calendar control in edit mode.  When the "save" button is clicked, the date selected by the calendar control needs to be saved to the database as the new value for the given field of the given document (i.e. instance of the form).  My initial idea was to create a special <code>DataControlField</code> class which, given a form field key, would know how to databind thusly:</p>
  
  <pre><code>FormDocument doc = DataBinder.GetDataItem(cell) as FormDocument;
  FormFieldValue fieldValue = doc.FieldValues[FieldKey];
  fieldValue.AddReadOnlyControls(cell);
  </code></pre>
  
  <p>... instead of:</p>
  
  <pre><code>Object dataObject = DataBinder.GetDataItem(cell);
  cell.Text = DataBinder.GetPropertyValue(dataItem, FieldKey);
  </code></pre>
  
  <p>This would probably work for displaying the field values, but if the user tries to edit and save one of the <code>FormDocument</code>s I don't know how I would convince the GridView to do something like this:</p>
  
  <pre><code>doc.FieldValues[FieldKey] = newValue;
  </code></pre>
  
  <p>Currently, the API for <code>DataControlField</code> uses the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datacontrolfield.extractvaluesfromcell.aspx" rel="nofollow noreferrer"><code>ExtractValuesFromCell</code></a> method to put the property name and value into an <code>IOrderedDictionary</code>.  Those values are then applied to the given properties of the objects in the GridView's databound <code>IEnumerable</code>.  The problem is, I can't work with properties of an object because in this case the object needs to have a completely arbitrary number of fields.</p>