I probably did not word this correctly so I will try again. The dynamic list code presented above works fine with one exeception. I only want the resulting datatable to display columns which are not primary or foreign keys. Since the resulting datatable will be bound to a datagrid, there is no need for a user to see the primary or foreign keys.
I think I may be going about this the wrong way. Maybe I should have the resultset contain just the columns I need(no primary or foreign key columns). But I couldn't figure out how to filter on values which are not in the resultset. So in the code above I have:
ResultsetFields fields = new ResultsetFields(9);
fields.DefineField(MilestoneFieldIndex.MilestoneId, 0, "MilestoneId");
fields.DefineField(MilestoneFieldIndex.Name, 1,"Name");
fields.DefineField(MilestoneDataFieldIndex.PlannedDate, 2,"PlannedDate");
fields.DefineField(StatusTypeFieldIndex.Name, 3, "Status");
fields.DefineField(MilestoneDataFieldIndex.ActualDate, 4,"ActualDate");
fields.DefineField(MilestoneDataFieldIndex.OrganizationPageId, 5, "OrganizationPageId");
fields.DefineField(MilestoneDataFieldIndex.TargetOrganizationPageId, 6, "TargetPageId");
fields.DefineField(MilestoneDataFieldIndex.CompanyId, 7, "CompanyId");
fields.DefineField(MilestoneFieldIndex.Description, 8, "Description");
So maybe my ResultsetFields should look something like this instead:
ResultsetFields fields = new ResultsetFields(5);
fields.DefineField(MilestoneFieldIndex.Name, 0,"Name");
fields.DefineField(MilestoneDataFieldIndex.PlannedDate, 1,"PlannedDate");
fields.DefineField(StatusTypeFieldIndex.Name, 2, "Status");
fields.DefineField(MilestoneDataFieldIndex.ActualDate, 3,"ActualDate");
fields.DefineField(MilestoneFieldIndex.Description, 4, "Description");
But how does one filter on columns which are not in the resultfields?
[Edit] Ok, I don't know what I was doing wrong before, but I modified the resultsetFields to use the second example and everything worked. So for now, I don't have any issues.