I am using the refresh even to reset the datasource for the calendar. I have some custom query fields that are brought in from the Request.Form that are passed to the SQL. It works fine in the initial page load. I store the custom fields in a global variable called addstuff. However when I call the SQL again in the refresh event the addstuff does not appear to work as the calendar returns all the events --not just the ones selected via the addstuff filter variables. I have tried to write out the SQL (via response.write and setting an asp label text), but this does not seem to work within the refresh method. Any help or sample code would be appreciated.
I may be missing something very basic as I normally program in VB
potected void DayPilotCalendar1_Refresh(object sender, RefreshEventArgs e)
{
DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstDayOfWeek(e.StartDate);
addstuff = addstuff;
mx= (e.StartDate.Month);
yx= (e.StartDate.Year);
dx= (e.StartDate.Day);
dex = dx + 7;
dbstring = mx +"/" + dx + "/" + yx;
destring = mx +"/" + dex + "/" + yx;
Convert.ToDateTime(mx +"/" + dx + "/" + yx);
// Response.Write("addstuff" + m);
DataTable dt;
dt= new DataTable();
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["daypilot"].ConnectionString))
{
con.Open();
// SqlDataAdapter ad = new SqlDataAdapter("SELECT [id], [ctype], [A1begin], [A1date], [allday] FROM [citystat] WHERE (([A1date] <= '" + destring + "' ) AND ([A1begin] >= '" + dbstring + "' ))", con);
SqlDataAdapter ad = new SqlDataAdapter("SELECT citystat.id, [ctype], [A1begin], [A1date], [allday] FROM [citystat] INNER JOIN csusers ON citystat.a1actor = CSusers.id INNER JOIN CSdepartments ON csusers.department = CSdepartments.id WHERE [A1date] <= '" + destring + "' AND [A1begin] >= '" + dbstring + "' " + addstuff + " ", con);
DataSet ds = new DataSet();
ad.Fill(ds,"Categories");
DayPilotCalendar1.StartDate = Convert.ToDateTime(e.StartDate);
DayPilotCalendar1.DataSource = ds;
}
DayPilotCalendar1.DataBind();
DayPilotCalendar1.Update();
}