I know I must be missing something. If I make changes to a datagriditem in the ItemDataBound event of the RadGrid the changes are not visible the first time the page loads, I don’t see the changes to the DataItem until I refresh the grid via the CommandItem for refresh. I have verified that the ItemDataBound event is fired and the values that I am replacing do infact have the correct values.
background:
I have a class that creates the RadGrid. It is then instantiated and loaded into the .aspx page via the code behind for the .aspx. This is a master/detail datagrid if that makes any difference.
protected void Page_Init(object source, EventArgs e)
{
this.__activeBatchesRadGrid = ActiveBatchesRadGrid.GridDefinition("ActiveBatchesRadGrid");
this.PlaceHolder1.Controls.Add(this.__activeBatchesRadGrid);
this.__activeBatchesRadGrid.ItemDataBound += new GridItemEventHandler(ActiveBatchesRadGrid_ItemDataBound);
}
private void ActiveBatchesRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
GridDataItem _dataItem = e.Item as GridDataItem;
if (_dataItem == null) return;
BatchStatusType _batchStatus = EnumUtils.GetValueFromName<BatchStatusType>(_dataItem["BatchStatusName"].Text);
Dictionary<BatchStatusType, BatchStatusType> _batchStatusTypes =
BatchTransitions.GetBatchStatusTransition(_batchStatus);
GridButtonColumn _btnPromote =
((GridButtonColumn) this.__activeBatchesRadGrid.MasterTableView.GetColumn("MasterPromoteRecord"));
GridButtonColumn _btnDelete =
((GridButtonColumn)this.__activeBatchesRadGrid.MasterTableView.GetColumn("MasterDeleteRecord"));
foreach (KeyValuePair<BatchStatusType, BatchStatusType> _item in _batchStatusTypes)
{
_btnPromote.Text = _item.Value.ToString();
_btnPromote.ConfirmText = string.Format("Are you sure you want to promote this batch to {0} status?",
_item.Value);
_btnDelete.Text = string.Format("Demote batch to {0} status.", _item.Key.ToString());
_btnDelete.ConfirmText = string.Format("Are you sure you want to demote this batch to {0} status?",
_item.Key);
}
}
I thought I would post the solution I put together that takes care of this problem. I do however, still believe that the proper implementation that I originally posted should work. If it works for all items other than the first datagrid row then I believe there is a shortcoming in the control.