|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Calendar control in a datagrid returns wrong dateI 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, //don't miss this check if you are databinding in Page_Load
if (!Page.IsPostBack ) datagrid1.DataBind(); Show quoteHide quote "Jon Prisbe" wrote: > 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, Thanks Phillip.
That was my problem. Show quoteHide quote "Phillip Williams" wrote: > //don't miss this check if you are databinding in Page_Load > if (!Page.IsPostBack ) > datagrid1.DataBind(); > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "Jon Prisbe" wrote: > > > 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,
Problem with User Control and unset references to controls within
GridView - can't reference value of a non-visible cell?? error in adding user controls at runtime Fitting a table inside an ASP Panel error using .NET CrystalReportViewer (.NET 1.1 VS.NET 2003) Gridview PostBack Problems WebControl rendering in frontpage 2003 - Migrating from Visual Studio 2003 to 2005 GridView Height InputAttributes in RowCreated (gridview) Re: Binding two fields in the DataNavigateUrlFormatString |
|||||||||||||||||||||||