I have a few Grid controls hooked to my data source. I am using Entity Framework CodeFirst. All of my model types have a GUID property called 'ID' as the key. My types are inheriting ID from an abstract base type (through a couple of layers of inheritance).
In one case, I'm using an proxy type where I have renamed this to 'RowID' and I have several other Guid 'ID's. The grid using this type works fine, and all of the GUID IDs are available as expected. All of the Guid columns in this case are prefixed: RowID, AID, BID, CID, etc. In this case, there is no inheritance, and all of the 'IDs' are in the base class.
In two other grids, I'm binding the grid to an IEnumerable<type> and setting a static column to use the DataField 'ID'. In these cases, the ID is not displayed or available in the GridItem -- the cell is always empty.
Code: HTML/ASPX
<Columns>
<eo:RowNumberColumn>
</eo:RowNumberColumn>
<eo:StaticColumn DataField="Name" HeaderText="Name" Name="Name">
</eo:StaticColumn>
<eo:StaticColumn DataField="ID" HeaderText="ID" Name="ID">
</eo:StaticColumn>
</Columns>
I have also tried setting the Grid KeyField to 'ID', and this also is consistently coming back as empty.
Note that the Grids in all cases are within user controls, and the databinding occurs within the overriddent DataBind of the user control.
Is there something special about the field name 'ID' or the field name ID as a GUID?
Another column in the type is dispalying (plain string). I have experimented with setting the DataType to Auto and to String without luck.
Code: C#
pseudocode
public override void DataBind
{
try
{
IEnumerable <myType> returnValue = repository.GetMyType();
this.Grid1.DataSource = returnValue;
this.Grid1.DataBind;
}
catch (Exception ex)
{
logger.log(ex);
}
}
When I debug, I can see the ID is in the returnValue (base type) for myType. Other properties in the base type will show up in the grid. So, I know that the value is there (at least at the time of databinding in the code behind), and I know that I can display content from the same level of the inheritance tree. I know I can see Guids (not named ID) from another Grid. I'm just not able to see the Guid 'ID' property.
Is there something that I should be looking for?