G
Guest
I have been loving the templated datacolumns of the datagrid. I have stumbled onto a problem though that is beyond by knowledge and I was hoping someone here could jumpstart me. My templated columns work find as long as I pass in a dataset but if I pass in a collection of objects then they won't work unless I can cast the correct object and then fill in the column with the object. My current code looks like this:
public void BindData(object sender, EventArgs e) {
Literal l = (Literal) sender;
DataGridItem container = (DataGridItem) l.NamingContainer;
Folder folder = (Folder) (((DictionaryEntry) container.DataItem).Value);
l.Text = folder[_column];
}
and it works fine as long as I know the object. But I can't figure out how to get it to work in a more generic manner - IE: I want to be able to determine the object on the fly, cast it and then have the BindData method populate the column from the _column in the object without knowing what the object is in advance.
Anyone have any pointers they'd like to share to get me in the right direction?
Thanks,
Alex
public void BindData(object sender, EventArgs e) {
Literal l = (Literal) sender;
DataGridItem container = (DataGridItem) l.NamingContainer;
Folder folder = (Folder) (((DictionaryEntry) container.DataItem).Value);
l.Text = folder[_column];
}
and it works fine as long as I know the object. But I can't figure out how to get it to work in a more generic manner - IE: I want to be able to determine the object on the fly, cast it and then have the BindData method populate the column from the _column in the object without knowing what the object is in advance.
Anyone have any pointers they'd like to share to get me in the right direction?
Thanks,
Alex