0

I have a legacy app that uses Infragistics UltraWebGrid and am running into a particularly infuriating issue.

In runtime a column is added with checkboxes. When users hits save, it adds all users that are checked to a db. I have to add code to validate if a checked user is in fact active before allowing the save. I set up my test data where the first one checked in inactive and the second one checked is fine. However, when I debug my code, it SOMETIMES sees that cell.Selected is true, but usually does not (2/10 times). It ALWAYS sees that the 2nd one's cell.Selected is true.

This leads me to believe that UltraWebGrid does some sort of lazy eval and doesn't update the table from the UI thread right away.... what's going on here?

EDIT

Just realized I've been using the cell.Selected property this whole time, which is not equal to Checked... not sure how to get the Checked value out though...

foreach (UltraGridRow row in uwgRoster.Rows)
{
    foreach (UltraGridCell cell in row.Cells)
    {
        if (cell.Column.Type == ColumnType.CheckBox && cell.Key.ToLower().Contains("service") && cell.Selected)
        {
            var casefileId = row.Cells.FromKey("CasefileID").Value.ToString();
            var casefile = new Casefile(Convert.ToInt32(casefileId), false);

            if (!casefile.ActiveFlag)
            {
                inactives.AppendLine("- " + row.Cells.FromKey("Name").ToString());
            }
        }
    }
}
Hershizer33
  • 1,206
  • 2
  • 23
  • 46
  • 1
    Are you sure that you check if a cell is checked using the Selected property? I think you need to use the Value property cast to a boolean. Let me know if this is the case. – Steve Sep 17 '14 at 22:23
  • Yeah I noticed that too. hence the update haha. I did try the value cast but occasionally it would throw an exception because Value would come through as a string set to "true" instead of a bool. Any idea why that would happen? – Hershizer33 Sep 17 '14 at 23:13
  • 1
    Do you know the Column.Key value of your column? There is no need to traverse every Column to find the column with the CheckBox that you want to process. You should use the Value property to find your value. It is just a matter to cast correctly the underlying value. – Steve Sep 18 '14 at 07:12
  • I have to traverse just because of the way page is setup. Back to the value thing... sometimes it comes in as bool true and sometimes it comes in as string "true"... so if I do the hard cast it throws exceptions on the string case. Do you know why it would be different each time? Should I switch on type to assign it correctly? – Hershizer33 Sep 18 '14 at 14:13
  • 1
    The use the property Text (a string). That should be more easy – Steve Sep 18 '14 at 14:30
  • Thanks. As an aside do you know how to set the data type of a column? I tried `col.Datatype = typeof(bool);` but that threw `Cannot implicitly convert type 'System.Type' to 'string'` – Hershizer33 Sep 18 '14 at 14:33
  • 2
    It is just a string. So `col.DataType = "System.Boolean";` – Steve Sep 18 '14 at 15:04

0 Answers0