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

In my Code I must update DropDownList. It updeting but only when the page is refreshing. So i want to after finished adding item it should be redirect bact to the site. I made a Code:

    public class EventReceiver1 : SPItemEventReceiver
{
    HttpContext current;
    public EventReceiver1()

{ current = HttpContext.Current; }

   /// <summary>
   /// An item is being added.
   /// </summary>
   public override void ItemAdding(SPItemEventProperties properties)
   {
       base.ItemAdding(properties);

       if (properties.List.Title == "Wpisy")
       {
           SPSite oSiteCollection = new SPSite("http://gzawistowskilap");
           SPWeb witryna = oSiteCollection.RootWeb;
           SPListItemCollection listaDniSwiatecznych = witryna.Lists["DR2013 Święta"].Items;
           SPList lstOtherList = properties.Web.Lists["Szczegoly"];

           // Stworzenie dwóch zmiennych typu data, jednej opisującej dzień Startowy, drugiej opisującej dzień końcowy
           DateTime dzienStart = new DateTime();
           DateTime dzienStop = new DateTime();

           // Podstawienie odpowiednich pól z propetisów pod wcześniej stworzone zmienne
           dzienStart = Convert.ToDateTime(properties.AfterProperties["DzienStart"]).ToUniversalTime();
           // Zaistniała też potrzeba odjęcia dwóch godzin
         // dzienStart = dzienStart.AddHours(-1.0);
           dzienStop = Convert.ToDateTime(properties.AfterProperties["DzienStop"]).ToUniversalTime();
         // dzienStop = dzienStop.AddHours(-1.0);
           // Uruchomienie pętli while, która to pętla będzie się wykonywać przez czas kiedy to zmienna dzienStart będzie mniejsza bądz równa zmiennej dzienStop


           while (dzienStart <= dzienStop)
           {
               foreach (SPListItem olistaDniSwiatecznych in listaDniSwiatecznych)
               {

                   if (dzienStart.ToShortDateString() == Convert.ToDateTime(olistaDniSwiatecznych["Data"]).ToShortDateString())
                   {
                       dzienStart = dzienStart.AddDays(1.0);
                       continue;
                   }
               }

                       // Sprawdzenie Ifem, czy wybrane dni są równe sobocie, lub niedzieli
                       if (dzienStart.DayOfWeek.ToString() == "Saturday" || dzienStart.DayOfWeek.ToString() == "Sunday")
                       {
                           // Jeżeli zmienna ciągle inkrementowana dzienStart jest równa sobocie, lub niedzieli, to wwtedy następuje powiększenie dnia o jeden, zaś potem następuje kontynuacja pętli
                           dzienStart = dzienStart.AddDays(1.0);
                           continue;
                       }
                       // W przeciwnym wypadku następuje dodanie obiektu do listy
                       else
                       {
                           SPListItem item = lstOtherList.Items.Add();
                           item["Kontrakt"] = properties.AfterProperties["Kontrakt1"];
                           item["Pracownik"] = properties.AfterProperties["Pracownik1"];
                           item["Dzien"] = dzienStart;
                           item["Procenty"] = properties.AfterProperties["Procenty"];
                           // item["ID z Czas Pracy Wpisy"] = properties.BeforeProperties["ID"];
                           dzienStart = dzienStart.AddDays(1.0);
                           item.Update();
                       }


           }

           SPUtility.Redirect("http://gzawistowskilap/SitePages/Event.aspx?InitialTabId=Ribbon.ListItem&VisibilityContext=WSSTabPersistence", SPRedirectFlags.Default, current);

       }



   }
   // Koniec ItemAdding

But there after finished addingit's update secandary list not first, and write me all in modal window, not in the site. I want to see this refreshing on the site.

share|improve this question
NoOne Knows a answer ? – Grzegorz Z Nov 6 '12 at 19:01

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.