DetailsView validation fields

I create a detailsview to insert data in a table but I don't know how to validate each field that is typed in the page before sending the information to the database.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

convert the boundfields to template fields and add validators

instead of
<asp:BoundField DataField="eventTitle" HeaderText="Title" SortExpression="eventTitle" HtmlEncode="false" />

                                          <asp:TemplateField HeaderText="Title">
                                                      <%# Eval("eventTitle") %>
                                                      <asp:RequiredFieldValidator ControlToValidate="txtEventTitle" ID="RequiredFieldValidator1" runat="server" Text="You must enter a title<br>"></asp:RequiredFieldValidator>
                                                      <asp:TextBox ID="txtEventTitle" MaxLength="50" runat="server" Text='<%# Eval("eventTitle") %>'></asp:TextBox>
and for the parameters
                  <asp:ControlParameter ControlID="dvEventDetails$txtEventTitle" Name="eventTitle" />
CarolinatAuthor Commented:
Thanks, It worked but the insert link doesn't do anything. What code do I have to add?
Do you have an insert command and insert parameters on your SqlDataSource?  When you say doesn't do anything, do you mean the page doesn't change, or that no form is displayed?  Is there a JavaScript error?
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

CarolinatAuthor Commented:
I'm using a Detailsview to create an insert form. Now, I can validate some fields that can't be nulls but when I fill out all of the fields and then click in Insert link it showed me a page with the following error and I don't know why the insert doesn't take the values I'm typing in the form.

Cannot insert the value NULL into column 'BoxNum', table 'Venus.dbo.Boxes'; column does not allow nulls. INSERT fails.
The statement has been terminated.
post your insert parameters

the insert parameters will now need to be in the form of

<asp:ControlParameter ControlID="detailsViewID$textBoxID" Name="eventTitle" />

for all of them, replace the two IDs with the actual controls IDs, do that for all of them  dvID$controlID

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CarolinatAuthor Commented:
I have this

                <asp:Parameter Name="BoxNum" Type="Int64" />
                <asp:Parameter Name="Status" Type="String" />
                <asp:Parameter Name="DateClose" Type="DateTime" />
                <asp:Parameter Name="DateOpen" Type="DateTime" />
                <asp:Parameter Name="User" Type="String" DefaultValue="CAROLINA" />
but still shows me the same error.
CarolinatAuthor Commented:
What should I write in--> Name="eventTitle" ?
CarolinatAuthor Commented:
Thanks, it works perfect.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.