I need to know how I can pass my calendar selected date from my default page to my redirect page. Here's my code behind:
Default page – Calendar
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "Welcome, " + Session["UserName"].ToString();
if (!IsPostBack)
{
if (Session["UserName"].ToString() != null)
{
string SessionName = Session["UserName"].ToString();
}
}
}
protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)
{
FormsAuthentication.SignOut();
Response.Redirect("Login.aspx");
}
protected void Calender1_DayRender(object source, DayRenderEventArgs e)
{
// Declare the query string.
OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
OracleCommand myCommand = new OracleCommand("SELECT to_date(a.PROJECT_DUE,'MM/DD/YYYY') FROM NEW_PROJECTS a WHERE upper(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "' or upper(a.ASSIGNED_ID) = '" + Session["UserName"].ToString() + "'or lower(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString() + "'and a.proj_status = 'Active'", myConnection);
OracleDataReader dr;
myConnection.Open();
dr = myCommand.ExecuteReader();
while (dr.Read())
{
//assign the calendar control dates already contained in the database
Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0));
e.Cell.Text = "<a href='edit_project.aspx?PROJECT_DUE=" + e.Day.Date.ToString("MM/dd/yyyy") + "'>" + e.Day.DayNumberText + "</a>";
}
dr.Close();
myConnection.Close();
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
OracleCommand myCommand = new OracleCommand("SELECT PROJECT_NAME, PROJECT_DUE, REQUESTED_MANAGER, PROJ_DESCRIPTION, PROJ_CATEGORY, PROJ_STATUS, ASSIGNED_TO, PRIORITY_LEVEL FROM NEW_PROJECTS WHERE PROJECT_DUE = '" + Calendar1.SelectedDate.ToString("MM/dd/yyyy") + "'", myConnection);
OracleDataReader dr;
myConnection.Open();
dr = myCommand.ExecuteReader();
while (dr.Read())
{
Response.Write(dr.GetString(0));
Response.Write(dr.GetString(1));
Response.Write(dr.GetString(2));
Response.Write(dr.GetString(3));
Response.Write(dr.GetString(4));
Response.Write(dr.GetString(5));
Response.Write(dr.GetString(6));
Response.Write(dr.GetString(7));
}
}
}
Redirect page
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LoadData();
}
}
protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)
{
FormsAuthentication.SignOut();
Response.Redirect("Login.aspx");
}
protected void btnShowCal_Click(object sender, EventArgs e)
{
Calendar1.Visible = true;
}
/************************************************************/
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
Project_Due.Text = Calendar1.SelectedDate.ToString("MM/dd/yyyy");
Calendar1.Visible = false;
}
protected void LoadData()
{
//load data
OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
OracleCommand myCommand = new OracleCommand("SELECT PROJECT_NAME, PROJECT_DUE, REQUESTED_MANAGER, PROJ_DESCRIPTION, PROJ_CATEGORY, PROJ_STATUS, ASSIGNED_TO, PRIORITY_LEVEL FROM NEW_PROJECTS WHERE PROJECT_DUE = '" + Calendar1.SelectedDate.ToString("MM/dd/yyyy") + "'", myConnection);
OracleDataReader dr;
myConnection.Open();
dr = myCommand.ExecuteReader();
while (dr.Read())
{
Project_Name.Text = (string)dr["Project_Name"];
Project_Due.Text = (string)dr["Project_Due"]; //this is the problem due date is not binding with the calendar selection date
Requested_Manager.SelectedValue = (string)dr["Requested_Manager"];
Proj_Description.Text = (string)dr["Proj_Description"];
Proj_Category.SelectedValue = (string)dr["Proj_Category"];
Proj_Status.SelectedValue = (string)dr["Proj_Status"];
Assigned_To.SelectedValue = (string)dr["Assigned_To"];
Priority_Level.SelectedValue =(string)dr["Priority_Level"];}
myConnection.Close();
}
}
}