I’m working on a project which builds a KML file, taking GPS coordinates and creating placemarks for each point…
Then another feature is about changing the picture style if something is true.
More detailed:
I have a List of strings with the values stored from a gridview. The list contains both elements with dates and empty ones as well. Then I have to check for the one which are not empty – set picture1, else set defaultPic.
Here is the code:
for (int i = 0; i < latList.Count; i++) //looping through all the coordinates
{
kml.WriteStartElement("Placemark");
kml.WriteElementString("name", "Point " + GridView1.Rows[i].Cells[0].Text);
if (datesList.Any(dates => !String.IsNullOrEmpty(dates) && dates != " ") )
{
kml.WriteElementString("styleUrl", "#randomColorIcon");
}
else
{
kml.WriteElementString("styleUrl", "#randomColorIcon2");
}
I get the KML file with all the same picture(“randomColorIcon”). Since I have 3 values in the date column in the gridview (3 not empty values in the datesList respectively) I need to get 3 points with different picture, and all the others with the default one…
SO there is something wrong with the if statement but I don’t really get it now. Sorry if something is not clear, I will try to fix it..
Any directions or suggestions are very welcome. Hope you can understand what do I mean with all this and help… 🙁
Desired KML file (There are 3 points which has dates in the database, all the other Points have the same picture)

Hope it is visible…
Thanks guys
Try this