In my ASP.NET (c#) application using syncfusion schedule, I am trying to get a value from a dictionary based on the key.
When I try to do that I get this error message:
System.Collections.Generic.KeyNotFoundException: 'The given key was not present in the dictionary.
This line of code (where I try to get the value of key 'Subject' and assign it to variable sSubject
) throws the error:
string sSubject = list["Subject"].ToString();
Code:
public Dictionary<string, object> Arguments { get; set; }
protected void Schedule1_ServerAppointmentEdited(object sender, Syncfusion.JavaScript.Web.ScheduleEventArgs e)
{
Arguments = e.Arguments["appointment"] as Dictionary<string, object>;
dynamic list = Arguments as Dictionary<string, object>;
string sSubject = list["Subject"].ToString();
}
If I debug my code to look what's in my dictionary, I do see that key 'Subject' is present:
What am I doing wrong? How can I get value 'test subject' from key 'subject'?
Project: http://www.syncfusion.com/downloads/support/forum/119417/ze/ScheduleCRUDWithWebServices-728709208
Documentation: https://www.syncfusion.com/kb/5182/how-to-perform-the-crud-operation-in-the-schedule-control-with-webservices-datasource
Thank you
This is how I finally retrieved the value of key 'subject':
Arguments = e.Arguments["appointment"] as Dictionary<string, object>;
//dynamic list = Arguments as Dictionary<string, object>;
System.Collections.ArrayList list2 = (System.Collections.ArrayList)Arguments["changed"];
Dictionary<string, object> dic = (Dictionary<string,object>)list2[0];
string sSubject2 = dic["Subject"].ToString();