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
if (e.CellElement.ColumnInfo is GridViewCommandColumn)
{
#region MyRegion
RadButtonElement button
= (RadButtonElement) e.CellElement.Children[0];
if
(e.CellElement.ColumnInfo.Name == "colUpdate" ||
e.CellElement.ColumnInfo.Name == "colDelete")
button.Enabled = false;
else
button.Enabled = true;
#endregion
}
}
else
{
cellElement.Enabled = true;
if (e.CellElement.ColumnInfo is GridViewCommandColumn)
{
#region MyRegion
//we get the RadButtonElement instance from the cell
RadButtonElement button
= (RadButtonElement)e.CellElement.Children[0];
button.Enabled = true;
#endregion
}
}
}
}
ليست هناك تعليقات:
إرسال تعليق