Use the TodaysDate property to determine today's date. You can also use this property to programmatically set the value for today's date on the
Calendar control.
Can you please post C# code in which I am able to select a datadriven date from calendar and once the date is selected data is populated into a form. This sounds simple but difficult to do. PLEASE HELP!
Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0)); is displaying my dates from the database, but when I select it is not giving me the right date,
I am getting the minvalue set(01/01/0001).
If the values are binding properly first time and while selecting it is not gettimg that means the values are not eprsisited. Can you just confirm while selecting it is not binding again may be thats hw values not persisted
Chetan Sarode
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
When I click my highlighted calendar date, it shows the date selected but when I redirect to the next page it is not populating the correct selected calendar date. It is populating 01/01/0001. What am I doing wrong? This is really weird. Somehow I need
to pass the selected date to my next page, how to do that??? Please look through my code and let me know what I am missing. This might be clear to me.
Cadeey
Member
102 Points
55 Posts
Re: Display user name in the header when logged in
Nov 04, 2009 02:39 AM|LINK
Thanks Chetan. Please try to help me as I'm soo frustrated with this calendar thing. When can I expect to see a solution???
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: Display user name in the header when logged in
Nov 05, 2009 02:11 AM|LINK
Use the TodaysDate property to determine today's date. You can also use this property to programmatically set the value for today's date on the Calendar control.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.calendar.todaysdate.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Cadeey
Member
102 Points
55 Posts
Re: Display user name in the header when logged in
Nov 05, 2009 07:26 PM|LINK
Chetan, this is not helping me at all.
Can you please post C# code in which I am able to select a datadriven date from calendar and once the date is selected data is populated into a form. This sounds simple but difficult to do. PLEASE HELP!
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: Display user name in the header when logged in
Nov 06, 2009 01:57 AM|LINK
You mean to say that following line didn't set the dat what you want, correct
//assign the calendar control dates already contained in the database
Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0));
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Cadeey
Member
102 Points
55 Posts
Re: Display user name in the header when logged in
Nov 06, 2009 02:59 AM|LINK
yes
Cadeey
Member
102 Points
55 Posts
Re: Display user name in the header when logged in
Nov 06, 2009 03:06 AM|LINK
For some reason this code of line:
Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0)); is displaying my dates from the database, but when I select it is not giving me the right date, I am getting the minvalue set(01/01/0001).
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: Display user name in the header when logged in
Nov 09, 2009 02:04 AM|LINK
If the values are binding properly first time and while selecting it is not gettimg that means the values are not eprsisited. Can you just confirm while selecting it is not binding again may be thats hw values not persisted
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Cadeey
Member
102 Points
55 Posts
Re: Display user name in the header when logged in
Nov 09, 2009 09:13 PM|LINK
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();
}
}
}
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: Display user name in the header when logged in
Nov 10, 2009 02:07 AM|LINK
You have already done it
e.Cell.Text = "<a href='edit_project.aspx?PROJECT_DUE=" + e.Day.Date.ToString("MM/dd/yyyy") + "'>" + e.Day.DayNumberText + "</a>";
is there any issue with above code
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Cadeey
Member
102 Points
55 Posts
Re: Display user name in the header when logged in
Nov 10, 2009 02:15 PM|LINK
When I click my highlighted calendar date, it shows the date selected but when I redirect to the next page it is not populating the correct selected calendar date. It is populating 01/01/0001. What am I doing wrong? This is really weird. Somehow I need to pass the selected date to my next page, how to do that??? Please look through my code and let me know what I am missing. This might be clear to me.