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:
<aspetailsView ID="DetailsView1" runat="server"
DataSourceID="SqlDataSourceAllDocumentForDetailsView"
AutoGenerateRows="False" DataKeyNames="DocumentId"
DataMember="DefaultView" DefaultMode="Edit"
Caption="<br/><h1>Modifier un
document<br/> <i>Edit a document</i></h1>"
CssClass="DetailsView" BorderWidth="0px"
HorizontalAlign="Center">
<FieldHeaderStyle CssClass="DetailsViewHeader" />
<Fields>
<asp:TemplateField HeaderText="Titre
:<br> <i>Title:</i>">
<EditItemTemplate>
<asp:TextBox ID="txtEditName" runat="server"
Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Crée le
:<br> <i>Created on:</i>">
<EditItemTemplate>
<br />
<asp:Calendar ID="editCreationDateCalendar"
runat="Server" VisibleDate='<%# Eval("CreationDate") %>'
SelectedDate='<%# Bind("CreationDate")
%>'></asp:Calendar>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description
:<br/> <i>Description:</i>">
<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
:<br/> <i>Type:</i>">
<EditItemTemplate>
<br />
<aspropDownList runat="server"
ID="ddlEditType" DataSourceID="sqlDataAllDocumentTypes"
DataTextField="Name"
DataValueField="DocumentTypeId" SelectedValue='<%#
Bind("DocumentTypeId") %>'
OnDataBound="ddlEditType_DataBound">
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Comité
:<br/> <i>Committee:</i>">
<EditItemTemplate>
<br />
<aspropDownList ID="ddlEditCommittee"
runat="server"
AppendDataBoundItems="true"
DataTextField="Name" DataValueField="CommitteeId"
SelectedValue='<%# Bind("CommitteeId") %>'
OnLoad="ddlEditCommittee_Load">
<asp:ListItem Selected="True"
Value="">-</asp:ListItem>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Langue
:<br/> <i>Language:</i>">
<EditItemTemplate>
<br />
<aspropDownList ID="ddlEditLanguage"
runat="server" AppendDataBoundItems="true"
SelectedValue='<%# Bind("DocLanguage") %>'>
<asp:ListItem Value="FR">FR</asp:ListItem>
<asp:ListItem Value="EN">EN</asp:ListItem>
</aspropDownList>
</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>
</aspetailsView>
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:
<aspetailsView ID="DetailsView1" runat="server"
DataSourceID="SqlDataSourceAllDocumentForDetailsView"
AutoGenerateRows="False" DataKeyNames="DocumentId"
DataMember="DefaultView" DefaultMode="Edit"
Caption="<br/><h1>Modifier un
document<br/> <i>Edit a document</i></h1>"
CssClass="DetailsView" BorderWidth="0px"
HorizontalAlign="Center">
<FieldHeaderStyle CssClass="DetailsViewHeader" />
<Fields>
<asp:TemplateField HeaderText="Titre
:<br> <i>Title:</i>">
<EditItemTemplate>
<asp:TextBox ID="txtEditName" runat="server"
Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Crée le
:<br> <i>Created on:</i>">
<EditItemTemplate>
<br />
<asp:Calendar ID="editCreationDateCalendar"
runat="Server" VisibleDate='<%# Eval("CreationDate") %>'
SelectedDate='<%# Bind("CreationDate")
%>'></asp:Calendar>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description
:<br/> <i>Description:</i>">
<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
:<br/> <i>Type:</i>">
<EditItemTemplate>
<br />
<aspropDownList runat="server"
ID="ddlEditType" DataSourceID="sqlDataAllDocumentTypes"
DataTextField="Name"
DataValueField="DocumentTypeId" SelectedValue='<%#
Bind("DocumentTypeId") %>'
OnDataBound="ddlEditType_DataBound">
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Comité
:<br/> <i>Committee:</i>">
<EditItemTemplate>
<br />
<aspropDownList ID="ddlEditCommittee"
runat="server"
AppendDataBoundItems="true"
DataTextField="Name" DataValueField="CommitteeId"
SelectedValue='<%# Bind("CommitteeId") %>'
OnLoad="ddlEditCommittee_Load">
<asp:ListItem Selected="True"
Value="">-</asp:ListItem>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Langue
:<br/> <i>Language:</i>">
<EditItemTemplate>
<br />
<aspropDownList ID="ddlEditLanguage"
runat="server" AppendDataBoundItems="true"
SelectedValue='<%# Bind("DocLanguage") %>'>
<asp:ListItem Value="FR">FR</asp:ListItem>
<asp:ListItem Value="EN">EN</asp:ListItem>
</aspropDownList>
</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>
</aspetailsView>