some of buttons disabled and another buttons are enabled depending on condition
the problem is , if you sort the radgridview by clicking the header of data column these enabled buttons will be disabled and disabled buttons somtimes will be enabled , i tried ViewCellFormatting event but have the same problem.
You can see the attached screenshot before and after sorting ..
private void grvDepartment_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.RowIndex > -1) // not header
{
var cellElement = e.CellElement;
int departmentId = Convert.ToInt32(e.Row.Cells["DepartmentId"].Value);
ICollection<UserProfile> usersProfiles =
(from u in _outEntities.UserProfile.Local where u.DepartmentId == departmentId select u).ToList();
if (usersProfiles.Count > 0)
{
#region MyRegion
if (cellElement.ColumnInfo.Name == "DepartmentName")
cellElement.Enabled = false;
else if (cellElement.ColumnInfo.Name == "DepartmentAcronum")
cellElement.Enabled = false;
else cellElement.Enabled = true;
#endregion
var cell = cellElement as GridCommandCellElement;
if (cell != null)
{
#region MyRegion
if (cell.ColumnInfo.Name == "colUpdate")
cell.Enabled = false;
//cell.Visibility = ElementVisibility.Hidden;
else if (cell.ColumnInfo.Name == "colDelete")
//cell.Visibility = ElementVisibility.Hidden;
cell.Enabled = false;
else cell.Enabled = true;
//cell.Visibility = ElementVisibility.Visible;
#endregion
}
}
}
}
the problem is , if you sort the radgridview by clicking the header of data column these enabled buttons will be disabled and disabled buttons somtimes will be enabled , i tried ViewCellFormatting event but have the same problem.
You can see the attached screenshot before and after sorting ..
private void grvDepartment_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.RowIndex > -1) // not header
{
var cellElement = e.CellElement;
int departmentId = Convert.ToInt32(e.Row.Cells["DepartmentId"].Value);
ICollection<UserProfile> usersProfiles =
(from u in _outEntities.UserProfile.Local where u.DepartmentId == departmentId select u).ToList();
if (usersProfiles.Count > 0)
{
#region MyRegion
if (cellElement.ColumnInfo.Name == "DepartmentName")
cellElement.Enabled = false;
else if (cellElement.ColumnInfo.Name == "DepartmentAcronum")
cellElement.Enabled = false;
else cellElement.Enabled = true;
#endregion
var cell = cellElement as GridCommandCellElement;
if (cell != null)
{
#region MyRegion
if (cell.ColumnInfo.Name == "colUpdate")
cell.Enabled = false;
//cell.Visibility = ElementVisibility.Hidden;
else if (cell.ColumnInfo.Name == "colDelete")
//cell.Visibility = ElementVisibility.Hidden;
cell.Enabled = false;
else cell.Enabled = true;
//cell.Visibility = ElementVisibility.Visible;
#endregion
}
}
}
}