DetailsView Control, Validator Control


I am trying to add a RequiredFieldValidator Control to a template field in the DetailsView Control, here is the code:

<asp:TemplateField HeaderText="*First Name:" SortExpression="FName">
<asp:Label ID="Label1" runat="server" Text='<%# Bind("FName") %>'></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FName") %>' Width=200></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ErrorMessage="First Name is Required" ID="FNameValidator">

I get the following message :

The ControlToValidate property of 'FNameValidator' cannot be blank.

What am I doing wrong please help.


"Whatsoever ye would that men do unto you, do you even so unto them" (Mathew 7:12)
6/10/2005 6:35:48 PM 72751 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 43


you need to also provide the ID of the control which the RFV validates (with ControlToValidate property). So you probably want to validate the TextBox1 (in same InsertItemTemplate) so add ControlToValidate="TextBox1" to the RequiredFieldValidator declaration.


Teemu Keiski
Finland, EU
6/10/2005 6:44:54 PM
Thanks Joteke that worked great!

"Whatsoever ye would that men do unto you, do you even so unto them" (Mathew 7:12)
6/11/2005 1:25:41 AM

Similar Artilces:

Controlling the controls a validator validates
Hello, I want to control which controls appear for a validator when they go to controltovalidate dropdown in property grid.  Is the solution to create a designer for the control?  How do you regulate that?  I can't override the ControlToValidate property... Thanks.Brian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4). Well ur logic is true, thats the way, what u need to do is not override the property (cant), create another property, that implemen...

Creating a User Control validator that validates a control on the page, rather than inside the control.
I'm trying to create a custom user control that is nothing more than a RangeValidator that validates other controls that lie on the page rather than inside the control itself... is this possible, is there a way to "bubble" it up. Thanks, G My answer to your other question regarding the CompareValidator applies here. If the custom control is in the same naming container AND does not implement INamingContainer, you can create a property that lets the user assign the control to validate. Internally assign the Validator.ControlToValidate property to the value of that property.-...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

How do I control one control from another control?
I have a page page1.aspx which is within a master page. On page I have a table with two cells. Within each cell I have placed two controls (ascx) that I have developed. Now I'd like to be able to get these two controls to interact. One needs to update the other. One has some search criteria that the other one needs to update its gridview. One needs to make the other visible/not visible at certain times. Out of the box neither control can see each other at all. Is there a good article or someplace I can find some information on how to do this? Information Technolo...

User Controls not working if I put Validation controls in user control
Hi           I have validation controls(RequiredField Validator,RegularExpressionValidator)  in user controls.User controls are not posting back like the events are not wiring up.If I remove Validation controls in User controls page,user controls are working fine.Can anyone please help me out in getting it fixed. In the Validation controls, make sure you are setting the ControlToValidate property to the control that it links to.  If you're in .NET 2.0, it's also a good idea to put all the validation controls in the same Valid...

Validation Controls with TabStrip Control
I'm trying to use a TabStrip control with Validation controls - required field validators - two of the tabs have required fields in them. The 'Save' button, in this case, shows on every Tab, so that, at any time, people can Insert the data into the database. When I use the Validation Summary - then, the only fields that are Validated, are the ones on the currently visible Tab - - I need to find out if there any way around that, so that all fields are summarized, whether the tabs are currently visible or not? ...

validation controls in gridview control
hi, I m using the grid view to add,edit,update,delete the data table. Everything is fine.In the footertemplate i get the values through text boxes and drop down lists.i took place sm validation controls to validate these controls.the problem arises here.if i want to update the record after i click the edit button, it validate the page n dont allow me to update the record.I want to validate the particular controls only. i checked if any causes validation property for update button.there is nothing like that. pls help me.. thanks in advance gowri  regards,gowripillaimark as answer if...

Validation controls are triggereing other forms validation controls?
Can someone please look at this an explain whats going on. When you click on subscribe it triggers my registration form validation controls. I'not sure what "subscribe" is supposed to do, but if you dont want it to cause validation, set the CausesValidation property to false.Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: Make sure the feild is an email address Hey coolkidsonly, your initial posting didn't show us anything to look at. We are just guessing here without the specifics. However, m...

Accessing Controls in a DetailsView Control
I'm using a DetailsView control to Insert Data into a SQL Server Database i have a textbox and two Calendar controls in it. I need to do some validation before inserting the data. I tried out some validation code with a customvalidator with the same controls outside a detailsview... this is my code:protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) { int days = Convert.ToInt32(TextBox1.Text); if (Calendar1.SelectedDate > Calendar2.SelectedDate) { Label1.Text = "Incorrect Date selection&q...

Validation Control question
Hello.  I have a form with several validation controls checking input boxes.  This form also has a DDL (dropdownlist).  This form also has a formview control in insert mode - this formview control has the validation controls.  The formview visibility is set to false. When a user selects an item from the DDL (which causes a postback) I set the visibilty of the formview to true.  At this point the validation controls are showing errors in th evalidation summary even though the user has not attempted to do any inputs. Where or how can I control when the validation ...

How to display all of my validation controls in my Validation summary control?
I have a  validation summary control I am using on a web form to validate various controls on a web form. For one of the controls  which is a text box control, I have a custom validation control. When someone presses the save button, all of the controls are validated. If any errors occur, then the error message is displayed in the validation summary area above all of the controls. This is what I want. The problem though is that I also get an error message next to my text box which was assigned the custom validator control. The problem here is that the error message i...

Wizard Control
I have a wizard control. I some steps i want to disable the Causes Validation of the StepNextButton and for other steps i want to enable. When i convert the StepNextButton to template and set CausesValidation to false, its applied to all the steps. How could i control the properties of the Next Previous buttons of different steps and set the properties individually? ThanksMark post(s) as "Answer" that helped youElectronic ScrewWebsite||Blog|| Link into one of the events that fire when the step changes. Then check to see if its a step that you want to disable validation....

Validation Control in the User Control
I have phone(4 boxes for area code, phone no, ext.) user control, and placed the custom control in the user control. I have used this user control in the page, validation control error messages won't show up. Any help would be great. Suresh    ...

DetailsView control and Button control
Hello Can someone help in next problem:  On page i have DetailsView control which return from SqlDataSource1 one record with seven columns. Along every row in DetailsView control I have one button control, for which I want, when I press one of the buttons (for example, first button which is placed along first row), that value in that first row of DetailsView gets greater (or smaller, whatever) value, and that value must be stored back in database. For example, that first field in DetailsView has name Point and value 10. When I click a button named btnPoint, along that...

Web resources about - DetailsView Control, Validator Control -

Visual Studio 2008 and .NET Framework 3.5 Service Pack 1 Beta
In this article, Scott discusses the recently released beta version of Visual Studio 2008 and .NET Framework 3.5 Service Pack 1. He starts with ...

Latest Updates
Latest Updates - Free source code and tutorials for Software developers and Architects.; Updated: 15 Feb 2013 - Upcoming stories is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

<asp:DetailsView ID="grd_empDetails" runat="server" DataSourceID="empDataSource -
Pastebin launched a little side project called , check it out ;-) Don't like ads?

Top Ranked Articles
Top Ranked Articles - Free source code and tutorials for Software developers and Architects.; Updated: 23 Feb 2013

Latest Updates
Latest Updates - Free source code and tutorials for Software developers and Architects.; Updated: 15 Feb 2013

Resources last updated: 12/9/2015 10:04:27 AM