Solved

CustomValidator in Datagrid ItemTemplate

Posted on 2004-10-21
598 Views
Last Modified: 2012-05-05

  I have a datagrid that has two item templates,
     1.) with a drop down list
     2.) with a textbox and CustomValidator

  On the postback I am iterating through the datagrid and ensuring that the text box is filled for certian selections in the drop down list.  
 
  When I find one that is in error I set the custom validator as such.
 
  validTest.ErrorMessage = "testing summary validator";
  validTest.IsValid = false;

  Unfortunately within the datagrid the validator does not appear "*" and the summary validator does not appear with the text.

   If I use a CustomValidator in the same fashion and same section of code that resides outside of the datagrid, the validator works as I expected.

  Anyone have any thoughts on this.  

  Thanks for the read.

0
Question by:dlarlick
    3 Comments
     
    LVL 6

    Accepted Solution

    by:
    Hmm. its the travesty of event modelling in asp.net. Their design is not completely fool proof. Recently I had the same problem. I was using datagrid to handle some data, then I was trying to bind server side errors to the validation summary control using the ErrorMessage property of CustomValidator. Unfortunately, it never worked.
    So, I created a custom control with the guidance from the following article, it worked seemlessly. Now, my server side errors bind as expected to the validation summary. Read through the article and let me know if you have any questions. I am using the approach in this article to solve this problem, in a live application. So, trust me it works

    http://www.codeproject.com/aspnet/validationsummary.asp
    0
     
    LVL 2

    Author Comment

    by:dlarlick

      Thanks for the post.
     
      I will take a look later today when I have some time.  



         
    0
     
    LVL 2

    Author Comment

    by:dlarlick

      Thank you...

       Will do the trick...  I'll have to use a label next to the textbox, but I don't see any other alternatives.

       Works well and solves another issue that I had nagging me elsewhere.

       Gold Star!!
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    877 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now