I have two calendars, I created workflow that creates item to second calendar when item created in first calendar. in second calendar i created column 'Id odsustvo' where the workflow set item id of first list. I tryed that create event receiver, but he is not working. i cannot delete item in second list when is deleted item in first list. code is next
- using System;
- using System.Security.Permissions;
- using Microsoft.SharePoint;
- using Microsoft.SharePoint.Security;
- using Microsoft.SharePoint.Utilities;
- using Microsoft.SharePoint.Workflow;
-
- namespace brisanje_stavke_iz_karneta_eventreceiver.EventReceiver1
- {
-
-
-
- public class EventReceiver1 : SPItemEventReceiver
- {
- private static string ID;
-
-
-
- public override void ItemDeleting(SPItemEventProperties properties)
- {
- base.ItemDeleting(properties);
- ID = properties.ListItem["ID"].ToString();
- }
-
-
-
-
- public override void ItemDeleted(SPItemEventProperties properties)
- {
- string ID1 = ID;
- int IDConverted = Convert.ToInt32(ID1);
- SPSite ListSite = new SPSite(properties.Web.Url);
- SPWeb ListWeb = ListSite.OpenWeb();
- SPQuery query = new SPQuery();
- query.Query = "" +
- "" +
- "" +
- "ID1Converted" +
- "" +
- "";
- SPListItem KarnetItem = ListWeb.Lists["Karnet"].GetItems(query)[0];
- KarnetItem.Delete();
-
- base.ItemDeleted(properties);
- }
-
-
- }
- }
i tryed that assign value item id to variable ID in ItemDeleting. next this variable i use for filtering second list query.Query, then selected item i delete with KarnetList.Delete(); , but nothing.
I noticed that my code deletes an item from calendar view of the second list, but not from all items view. why?
Some guide for my help?