Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have got two lists. One withthe working days, and secound with holly days. I must find and worry a person who is working in holly days. I put two querys.

  SPWeb witryna1 = SPContext.Current.Web;
        var query2 = new SPQuery();
        query2.Query = String.Format(DateOnlyQuery, "Data", dateISO);
        query2.ViewFields = "<FieldRef Name='Data' />";
        query2.ViewFieldsOnly = true;
        SPListItemCollection listaDniSwiatecznych = witryna1.Lists["DR2013 Święta"].GetItems(query2);
        var query4 = new SPQuery();
        query4.Query = String.Format(DateOnlyQuery, "Dzien", dateISO);
        query4.ViewFields = "<FieldRef Name='Dzien' />";
        query4.ViewFieldsOnly = true;
        SPListItemCollection listaDniProjektowych = witryna1.Lists["Szczegoly"].GetItems(query4);

        foreach (SPListItem olistaDniProjektowych in listaDniProjektowych)
        {
            foreach (SPListItem olistaDniSwiatecznych in listaDniSwiatecznych)
            {
                e.Cell.Style.Add("background-color", "#FFFF00");
                e.Cell.CssClass = "dni_swiateczne";
                e.Cell.Controls.Add(new LiteralControl(("<p style='color:red; font-size:8px;'>" + olistaDniSwiatecznych["Data"].ToString().Substring(0, 10) + "</p>")));
                if (Convert.ToDateTime(olistaDniSwiatecznych["Data"]).ToShortDateString() == Convert.ToDateTime(olistaDniProjektowych["Dzien"]).ToShortDateString())
                {
                    Label1.Text += "Pracujesz w dzień świąteczny<br />";
                }
            }
        }

But it duplikate my walues, because I set up only one days on holy days lists, and its write me 4 times Label1.Text += "Pracujesz w dzień świąteczny<br />";

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.