Looping through assemblies in a dashboard

If I’m looping through a list of Assemblies from a dashboard, how do I pass multiple parameters…such as the JobNum(str) and the AssemblySeq (int)?

I moved this to a new topic since it isn’t related to the previous question, makes it easier to keep organized!

What do you mean multiple parameters? What does your loop look like?

If I was looping through a independent record set and needed to pass both a JobNum and the assembly seq in order to get the correct selected assembly to update. I can’t see how the following code would know which JobNum that AssemblySeq 2 belonged to?

var selectedAssembly = edvJobAsmbl.dataView.Table.Rows.Cast<JobEntryDataSet.JobAsmblRow>().FirstOrDefault(x => x.AssemblySeq==2);
selectedAssembly[“MyCustomField_c”] = “Also data!”;

It wouldn’t, that would just give you the first assembly in the table with seq 2 you can add && x.JobNum=“my job” to your condition

-Jose Gomez

Thanks Jose!
I seem to have some issue with the Cast portion on the following line?

var selectedAssembly = edvJobAsmbl.dataView.Table.Rows.Cast<JobEntryDataSet.JobAsmblRow>().FirstOrDefault(x => x.AssemblySeq==2 && x.JobNum=“00035356”);

Error: CS1061 - line 277 (406) - ‘System.Data.DataRowCollection’ does not contain a definition for ‘Cast’ and no extension method ‘Cast’ accepting a first argument of type ‘System.Data.DataRowCollection’ could be found (are you missing a using directive or an assembly reference?)

When you call the Cast method you need to tell it which type you are casting to. Like so:

edvJobAsmbl.dataView.Table.Rows.Cast<JobEntryDataSet.JobAsmblRow>()

If you continue to receive that message you probably don’t have Linq on that screen. You can import linq by adding a using statement:

using System.Linq;

If you still receive an error about linq not being available, then the screen was likely built without access to linq. If you’re on a version before 10.1.400.00 there are quite a few screens without it. There are ways to get around this but they’re either hackier than I recommend or too complex for a quick solution. You need to fall back to a solution that doesn’t involve linq. For instance, looping through the records and firing when you find the one you want.

foreach (DataRowView row in edvJobAsmbl.dataView) {
            if (string.Equals((string)row["JobNum"], "SomeJob", StringComparison.OrdinalIgnoreCase) 
                && (int)row["AssemblySeq"] == 2 ) {
                MessageBox.Show("We found the row we're looking for!");
            }
        }