Problem with a Calendar in DetailsView

J

jerome.decouenne

Hello all!

I send you this message because I'm a bit lost... I've tried to solve
my problem since yesterday, and I haven't found any solution, even here
"http://www.webswapp.com/codesamples...esamples/aspnet20/dependentlists/default.aspx".
The fact is that I want to put an asp:Calendar control in the
EditItemTemplate of a DetailsView. It works fine, until I select a day,
where i find this error : "Databinding methods such as Eval(), XPath(),
and Bind() can only be used in the context of a databound control.".
I think the problem comes from the calendar onselected event but I'm
not sure how to manage it.
Can somebody help me pliz?

Jérôme DECOUENNE

Here is my code:
<asp:DetailsView ID="DetailsView1" runat="server"
DataSourceID="SqlDataSourceAllDocumentForDetailsView"
AutoGenerateRows="False" DataKeyNames="DocumentId"
DataMember="DefaultView" DefaultMode="Edit"
Caption="<br/><h1>Modifier un
document<br/>&nbsp;&nbsp;<i>Edit a document</i></h1>"
CssClass="DetailsView" BorderWidth="0px"
HorizontalAlign="Center">
<FieldHeaderStyle CssClass="DetailsViewHeader" />
<Fields>
<asp:TemplateField HeaderText="Titre
:&lt;br&gt;  &lt;i&gt;Title:&lt;/i&gt;">
<EditItemTemplate>
<asp:TextBox ID="txtEditName" runat="server"
Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Crée le
:&lt;br&gt;  &lt;i&gt;Created on:&lt;/i&gt;">
<EditItemTemplate>
<br />
<asp:Calendar ID="editCreationDateCalendar"
runat="Server" VisibleDate='<%# Eval("CreationDate") %>'
SelectedDate='<%# Bind("CreationDate")
%>'></asp:Calendar>


</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description
:&lt;br/&gt;  &lt;i&gt;Description:&lt;/i&gt;">
<EditItemTemplate>
<br />
<asp:TextBox ID="txtEditDescription"
runat="server" Text='<%# Bind("Description") %>'
Rows="4" TextMode="MultiLine"
Width="339px"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type
:&lt;br/&gt;  &lt;i&gt;Type:&lt;/i&gt;">
<EditItemTemplate>
<br />
<asp:DropDownList runat="server"
ID="ddlEditType" DataSourceID="sqlDataAllDocumentTypes"
DataTextField="Name"
DataValueField="DocumentTypeId" SelectedValue='<%#
Bind("DocumentTypeId") %>'
OnDataBound="ddlEditType_DataBound">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Comité
:&lt;br/&gt;  &lt;i&gt;Committee:&lt;/i&gt;">
<EditItemTemplate>
<br />
<asp:DropDownList ID="ddlEditCommittee"
runat="server"
AppendDataBoundItems="true"
DataTextField="Name" DataValueField="CommitteeId"
SelectedValue='<%# Bind("CommitteeId") %>'
OnLoad="ddlEditCommittee_Load">
<asp:ListItem Selected="True"
Value="">-</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Langue
:&lt;br/&gt;  &lt;i&gt;Language:&lt;/i&gt;">
<EditItemTemplate>
<br />
<asp:DropDownList ID="ddlEditLanguage"
runat="server" AppendDataBoundItems="true"
SelectedValue='<%# Bind("DocLanguage") %>'>
<asp:ListItem Value="FR">FR</asp:ListItem>
<asp:ListItem Value="EN">EN</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<br />
<asp:Button ID="DetailViewUpdateButton"
runat="server" CommandName="Update" CommandArgument='<%#
Eval("DocumentId") %>'
Text="Update"
OnCommand="DetailViewUpdate_Command"></asp:Button>
<asp:Button ID="DetailViewCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel"
OnCommand="DetailViewCancel_Command"></asp:Button>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
</Fields>
</asp:DetailsView>
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top