Calendar control in a datagrid returns wrong date

J

Jon Prisbe

I have a datagrid. When the user presses "edit" I display a calendar control
in the 2nd cell. The cell's edit template is the calendar control.
The user selectes a date on the calendar and then presses "update".

Problem: the calendar always returns 1/1/01 when I call SelectedDate.

Here is my grid update code:
System.Web.UI.WebControls.Calendar cal = null;
cal = (System.Web.UI.WebControls.Calendar)e.Item.FindControl("Calendar1");
string date = cal.SelectedDate.ToShortDateString();

What am I doing wrong?

Thanks,
 
P

Phillip Williams

//don't miss this check if you are databinding in Page_Load
if (!Page.IsPostBack )
datagrid1.DataBind();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top