From: Jakub Cermak on
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