Hi.
I have a large system we are developing constantly which displays around 100 lists throughout the system. We have set up a configuration system for the lists, and 1 user control to handle them all.
All our datasources are custom classes.
When I need to combine two different properties of the class into 1 column, things get a bit tricky.
Example of a custom class:
Using reflection I can access the values of the Master class easily. This is the databind event of the custom ItemTemplate class:
But when I need values from the Child class, things get tricky. I have tried all methods thinkable to me, and am stuck with this.
Can anyone show me how I can access the values from the Child class?
I have a large system we are developing constantly which displays around 100 lists throughout the system. We have set up a configuration system for the lists, and 1 user control to handle them all.
All our datasources are custom classes.
When I need to combine two different properties of the class into 1 column, things get a bit tricky.
Example of a custom class:
public class Master { |
public int ID { get; set; } |
public string Name { get; set; } |
public Child FirstChild { get; set; } |
} |
public class Child { |
public int ID { get; set; } |
public string Name { get; set; } |
} |
Using reflection I can access the values of the Master class easily. This is the databind event of the custom ItemTemplate class:
void control_DataBinding(object sender, EventArgs e) { |
LiteralControl control = (LiteralControl)sender; |
GridDataItem container = (GridDataItem)control.NamingContainer; |
control.Text = dataItem.GetType().GetProperty("Name").GetValue(dataItem, null).ToString(); |
} |
But when I need values from the Child class, things get tricky. I have tried all methods thinkable to me, and am stuck with this.
Can anyone show me how I can access the values from the Child class?