I've been using event handlers to do some custom formatting, or calculations within grids for a while. I will usually write something like so, that accesses the TableCells by UniqueName:
void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
GridDataItem item = e.Item as GridDataItem;
if (item != null)
{
Do some work
....
item["ColName"].text = ...;
.....
}
GridFooterItem item = e.Item as GridFooterItem;
if (item != null)
{
Do the same work
....
item["ColName"].text = ...;
.....
}
}
To prevent code duplication, is there anyway i can use a base class or interface member to reference the TableCells by name?
void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
GridDataItem item = e.Item as GridDataItem;
if (item != null)
{
Do some work
....
item["ColName"].text = ...;
.....
}
GridFooterItem item = e.Item as GridFooterItem;
if (item != null)
{
Do the same work
....
item["ColName"].text = ...;
.....
}
}
To prevent code duplication, is there anyway i can use a base class or interface member to reference the TableCells by name?