detailsview cannot be validated


V

Vincent

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>
 
Ad

Advertisements

M

Manish

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
 
Ad

Advertisements

V

Vincent

thanks

Manish said:
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
 

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

Top