Reputation: 67
Im trying to disable a RadGridView row based on a value in that row? I have tried the below code in the RowLoaded event but it seems to disable all rows.
var isEnrolled = (from c in masterList
where c.StudentId == StudentID
where c.Rolls[0].RollId == item.RollId.ToString()
select c.IsEnrolled).FirstOrDefault();
if (isEnrolled)
e.Row.IsEnabled = false;
Can it be done in same event, so if a row contains the word "Confirmed" the row is disabled?
foreach(DataGridRow item in RollListGrid.Items)
{
//Disable row if it contains "Confirmed"
}
And one more, how can i check a checkbox in a row if the query returns true?
var isProspectiveStudent = (from c in masterList
where c.StudentId == StudentID
where c.Rolls[0].RollId == item.RollId.ToString()
select c.IsProspectiveStudent).FirstOrDefault();
if (isProspectiveStudent){
//Check the relevant checkbox
}
Thanks!!
Upvotes: 0
Views: 1316
Reputation: 67
I managed to achieve what I wanted to with the below code.
foreach (var x in e.Row.Cells)
{
if (((GridViewCell)x).Value != null && ((GridViewCell)x).Value.ToString() == "Confirmed" && x.Column.UniqueName.IndexOf("5") != -1)
{
e.Row.IsEnabled = false;
break;
}
}
Upvotes: 1