Problem with a Calendar in DetailsView

Discussion in 'ASP .Net Web Controls' started by jerome.decouenne, May 22, 2006.

  1. 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>
     
    jerome.decouenne, May 22, 2006
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.