Hey guys,
I have a few Lists of strings containing elements saved from a Gridview on the page.
(2 different gridviews with datasource from same database and table but showing different information)
I need to write a logic which is ~10 if statements checking some conditions and then write a KML string (setting a different picture of a placemark in Google Earth).
The code looks like that:
for (int i = 0; i < latList.Count; i++) // going through the list of latitudes and see how many are they - then create placemark for each one taking the latitude and longitude (from Gridview on the page)
{
kml.WriteStartElement("Placemark");
kml.WriteElementString("name", "Pad " + GridView1.Rows[i].Cells[0].Text);
for (int j = 0; j < datesList.Count; j++) // another for loop going through list of dates and for every empty element in the list and where the list of tasks contains "someString", write KML element with the appropriate picutre
{
string date = datesList[i];
string tasks = GridView2.Rows[i].Cells[0].Text;
if ((!String.IsNullOrWhiteSpace(date) && date != " ") && tasksList.Where(task => task.Contains("Pre-Commissioning")))
{
kml.WriteElementString("styleUrl", "#randomColorIcon2");
}
else
{
kml.WriteElementString("styleUrl", "#randomColorIcon");
}
}
So what I need in the if statement here is to use both conditions. But it seems that I cannot use the Where method of a list. Not even as one condition in the if...
I tried using list.Contains("") but still not getting the correct result.
The if statement has to check if both conditions are true and ONLY IF they are - write the first line of kml.WriteElementString... else set the normal picture of the placemark.
I hope it is understandable and you can point me in the right direction.
Sorry if something is unclear, please ask and I will try to explain it better.