detailsview cannot be validated

Discussion in 'ASP .Net' started by Vincent, Feb 19, 2008.

  1. Vincent

    Vincent Guest

    Hi,

    i created a detailsview in insert mode. In order to avoid that an user
    inserts nothing, i added a RequiredFieldValidator control.

    But i get this error:
    "Control 'DetailsView1' referenced by the ControlToValidate property of
    'RequiredFieldValidator1' cannot be validated"

    Why and how to avoid wrong (empty) input?
    Thanks
    Vincent

    <asp:DetailsView ID="DetailsView1" runat="server" DefaultMode="Insert">
    <Fields>
    <asp:BoundField DataField="groepnr" HeaderText="groepnr"
    InsertVisible="False"
    ReadOnly="True" SortExpression="groepnr" />
    <asp:BoundField DataField="groepna" HeaderText="groepna"
    SortExpression="groepna" />
    <asp:BoundField DataField="kleur" HeaderText="kleur"
    SortExpression="kleur" />
    <asp:CommandField ShowDeleteButton="True"
    ShowEditButton="True"
    ShowInsertButton="True" />
    </Fields>
    </asp:DetailsView>

    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
    ControlToValidate="DetailsView1"></asp:RequiredFieldValidator>
    Vincent, Feb 19, 2008
    #1
    1. Advertising

  2. Vincent

    Manish Guest

    Hi Vincent,

    You would need to use a TemplateField instead of boundField and put the
    Textbox control in the ItemTemplate of that templatefield and also put a
    requiredFieldValidator and set the controltoValidate property to the Textbox
    control.

    Also bind the Textbox control to the field in the table.

    Regards,
    Manish
    www.ComponentOne.com


    "Vincent" wrote:

    > Hi,
    >
    > i created a detailsview in insert mode. In order to avoid that an user
    > inserts nothing, i added a RequiredFieldValidator control.
    >
    > But i get this error:
    > "Control 'DetailsView1' referenced by the ControlToValidate property of
    > 'RequiredFieldValidator1' cannot be validated"
    >
    > Why and how to avoid wrong (empty) input?
    > Thanks
    > Vincent
    >
    > <asp:DetailsView ID="DetailsView1" runat="server" DefaultMode="Insert">
    > <Fields>
    > <asp:BoundField DataField="groepnr" HeaderText="groepnr"
    > InsertVisible="False"
    > ReadOnly="True" SortExpression="groepnr" />
    > <asp:BoundField DataField="groepna" HeaderText="groepna"
    > SortExpression="groepna" />
    > <asp:BoundField DataField="kleur" HeaderText="kleur"
    > SortExpression="kleur" />
    > <asp:CommandField ShowDeleteButton="True"
    > ShowEditButton="True"
    > ShowInsertButton="True" />
    > </Fields>
    > </asp:DetailsView>
    >
    > <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
    > ControlToValidate="DetailsView1"></asp:RequiredFieldValidator>
    >
    >
    >
    Manish, Feb 20, 2008
    #2
    1. Advertising

  3. Vincent

    Vincent Guest

    thanks

    "Manish" <> schreef in bericht
    news:D...
    > Hi Vincent,
    >
    > You would need to use a TemplateField instead of boundField and put the
    > Textbox control in the ItemTemplate of that templatefield and also put a
    > requiredFieldValidator and set the controltoValidate property to the
    > Textbox
    > control.
    >
    > Also bind the Textbox control to the field in the table.
    >
    > Regards,
    > Manish
    > www.ComponentOne.com
    >
    >
    > "Vincent" wrote:
    >
    >> Hi,
    >>
    >> i created a detailsview in insert mode. In order to avoid that an user
    >> inserts nothing, i added a RequiredFieldValidator control.
    >>
    >> But i get this error:
    >> "Control 'DetailsView1' referenced by the ControlToValidate property of
    >> 'RequiredFieldValidator1' cannot be validated"
    >>
    >> Why and how to avoid wrong (empty) input?
    >> Thanks
    >> Vincent
    >>
    >> <asp:DetailsView ID="DetailsView1" runat="server" DefaultMode="Insert">
    >> <Fields>
    >> <asp:BoundField DataField="groepnr" HeaderText="groepnr"
    >> InsertVisible="False"
    >> ReadOnly="True" SortExpression="groepnr" />
    >> <asp:BoundField DataField="groepna" HeaderText="groepna"
    >> SortExpression="groepna" />
    >> <asp:BoundField DataField="kleur" HeaderText="kleur"
    >> SortExpression="kleur" />
    >> <asp:CommandField ShowDeleteButton="True"
    >> ShowEditButton="True"
    >> ShowInsertButton="True" />
    >> </Fields>
    >> </asp:DetailsView>
    >>
    >> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
    >> ControlToValidate="DetailsView1"></asp:RequiredFieldValidator>
    >>
    >>
    >>
    Vincent, Feb 20, 2008
    #3
    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. DesignerX
    Replies:
    2
    Views:
    445
    Teemu Keiski
    Jul 24, 2003
  2. mallik
    Replies:
    3
    Views:
    745
    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=
    Jul 7, 2005
  3. Steve Murphy

    Highlight Required Field When Not Validated

    Steve Murphy, Jul 28, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    838
    Steve Murphy
    Aug 2, 2005
  4. Owen
    Replies:
    1
    Views:
    12,865
    S. Justin Gengo
    Sep 12, 2005
  5. Feege
    Replies:
    0
    Views:
    436
    Feege
    Dec 20, 2005
Loading...

Share This Page