Problem with a Calendar in DetailsView

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

  1. Guest

    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/viewsource.aspx?file=~/codesamples/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>
    , May 22, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shevek
    Replies:
    3
    Views:
    6,034
    Shevek
    Jun 23, 2004
  2. K B
    Replies:
    0
    Views:
    3,481
  3. Tamer Ibrahim

    How can I access a calendar control inside a detailsview control?

    Tamer Ibrahim, Jan 29, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    891
    Alvin Bruney [MVP]
    Jan 30, 2007
  4. Feege
    Replies:
    0
    Views:
    448
    Feege
    Dec 20, 2005
  5. aj
    Replies:
    0
    Views:
    1,328
Loading...

Share This Page