を使用して、カスタム カレンダーを作成しました <SharePoint:SPCalendarView id=spcalView runat="server"> </SharePoint:SPCalendarView>
。次に、いくつかのイベントをカレンダー リストに挿入しました。上記で作成したビュー spcalView にイベントを表示できます。このためSPListItemCollection
に、 function に渡しました (つまり、Calendar List からコレクションを取得しました) MakeSchedule()
。
private SPCalendarItemCollection MakeSchedule(SPListItemCollection calListItems)
{
SPCalendarItemCollection items = new SPCalendarItemCollection();
for (int i = 0; i < calListItems.Count; i++)
{
SPListItem item = calListItems[i];
DateTime StartTime = Convert.ToDateTime(item["EventDate"]);
DateTime EndTime = Convert.ToDateTime(item["EndDate"]);
string appointmentId = "";
if (item["AppointmentID"] != null)
appointmentId = item["AppointmentID"].ToString();
string clientID = "";
if (item["clientID"] != null)
clientID = item["clientID"].ToString();
string Description = "";
if (item["Description"] != null)
Description = item["Description"].ToString();
string Location = "";
if (item["Location"] != null)
Location = item["Location"].ToString();
string Title = "";
if (item["Title"] != null)
Title = item["Title"].ToString();
bool Recurrance = false;
if (item["fRecurrence"] != null)
Recurrance = (bool)item["fRecurrence"];
bool AllDayEvent = false;
if (item["fAllDayEvent"] != null)
AllDayEvent = (bool)item["fAllDayEvent"];
SPWeb web = SPContext.Current.Web;
string relativeURL = web.ServerRelativeUrl;
string absoluteURL = web.Url;
items.Add(
new SPCalendarItem()
{
ItemID = item["ID"].ToString(),
StartDate = StartTime,
EndDate = EndTime,
hasEndDate = true,
Title = Title,
Location = Location,
Description = Description,
IsAllDayEvent = AllDayEvent,
IsRecurrence = Recurrance,
CalendarType = (int)SPCalendarType.Gregorian,
BackgroundColorClassName="ApptCnfirmed",
DisplayFormUrl = relativeURL + "/_layouts/TestProj.Webparts/AppointmentsEdit.aspx"
}
);
}
return items;
}
ここでは、SPCalendarItemCollection に追加された各イベント アイテムに対して、DisplayFormUrl をアプリケーション ページに設定しました。そのため、Spcalendar ビューでイベントをクリックすると、クリックされたアイテムの ID と共にクエリ文字列としてアプリケーション ページにリダイレクトされます。
アプリケーション ページで ID を取得し、ID に基づいて currentLstItem を取得しました。しかし、それから、私が CalendarList に追加したカスタム フィールドを取得できません。
public partial class AppointmentsEdit : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
string ID = Page.Request.QueryString["ID"].ToString();//this Id is the unique id of the Appointment List
string Source=Page.Request.QueryString["Source"].ToString();
if (ID != "" && ID != null)
{
SPList lstApp = SPContext.Current.Web.Lists["Appointment"];
SPListItem currentLstItem = lstApp.GetItemById(Convert.ToInt32(ID.ToString()));
}
else
{
}
}
}
SharePoint のカレンダー リストにカスタム フィールドが追加されているため、これはカレンダー イベントを編集する適切な方法ですか? デザイナーを使用してみましたが、EditForm.aspx のコード ビハインドを取得できません。
前もって感謝します!!