Calendar resets SelectedDate

J

Jakub Cermak

Hello all,
I've a data-bound form as FormView. I use it only in update mode. I have a
Calendar control declared as
<asp:Calendar ID="BirthDate" runat="server" ValidationGroup="ProfileEditor"
SelectionMode="Day" SelectedDate='<%# Bind("ContactPersonBirthDate")
%>'></asp:Calendar>

Although the ContactPersonBirthDate is set to some date initially (retieved
from Linq2sql), when I click on update button (CommandName=update), the
SelectedDate of this Calendar control is set to 1.1.0001 (and therefore the
update in SQL database fails).
I found out that it happens only when I dynamically remove some controls (to
hide unimportant values if needed) in Load event, it I commented out the
deleting function, everything works OK. The hide function is very simple:
void HideControls(params string[] names)
{
foreach (var item in names)
{
var ctrl = FormView1.FindControl(item);
ctrl.Parent.Controls.Remove(ctrl);
}
}

I hope I made myself clear. Can you give me please some ideas why it's
happening and how can I fix it? I don't clearly see the connection between
resetting of the Calendar control to its default value and removing some
controls (which are in the same EditItemTemplate, but they aren't
connected).

Thanks in advance

Jakub Cermak
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top