Using Validation on Details View Visual Studio 2016 RRS feed

  • Question

  • User1203223878 posted

    Anyone please let me know how to add Validation on DetailsView in VS16 using Design View.

    Redirecting me to a weblink to achieve the above task will also very helpful to me.

    Friday, June 3, 2016 6:34 AM


  • User1724605321 posted

    Hi  Sixthsense,

    To ensure that the user enters required inputs in a correct format in the inserting interface of the DetailView Control, you should convert the BoundFields into TemplateFields and add the Validation Controls to the appropriate template(s). For example :

       <asp:DetailsView runat="server" ID="userDetails">
                        <asp:TextBox runat="server" ID="userName" />
                        <asp:RequiredFieldValidator runat="server" ID="userNameValidator"
                            ErrorMessage="Please enter the name" ControlToValidate="userName" />

    Please refer to below articles for details and demo :

    http://jennycoca.blogspot.sg/2012/02/validate-dataview-control-aspnet-c.html .


    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 3, 2016 7:01 AM