?
Solved

How Required Field validator  with details view or gridview in ASP.NET 2.0

Posted on 2007-12-04
5
Medium Priority
?
6,248 Views
Last Modified: 2013-11-07
Can anyone tell me how I can use the required field validator control with a field that is in a gridview or details view control?
0
Comment
Question by:edi77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:QPR
ID: 20408845
same as you would were it outside a gridview...

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtKeywords"
        ErrorMessage="YOu forgot to type something" Width="304px"></asp:RequiredFieldValidator>
0
 

Author Comment

by:edi77
ID: 20408933
ok thanks, so where inside here do i put that?

 <EmptyDataTemplate>
            <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
                DataKeyNames="LP" DataSourceID="SqlDataSource1" DefaultMode="Insert" Height="50px"
                Width="125px" OnItemInserted="DetailsView1_ItemInserted">
                <Fields>
                    <asp:BoundField DataField="DNA" HeaderText="DNA" SortExpression="DNA" />
                   
                   
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
                </Fields>
            </asp:DetailsView>
0
 
LVL 29

Expert Comment

by:QPR
ID: 20415491
Outside of the gridview tag, it doesn't make up part of the control. Just so long as it references the correct control then all is good.

</Fields>
</asp:DetailsView>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtKeywords"
        ErrorMessage="YOu forgot to type something" Width="304px"></asp:RequiredFieldValidator>

The control would be a textbox for example (not the details view) so make sure the control has an id value
0
 

Author Comment

by:edi77
ID: 20418142
where can i make sure it has an id value  ? WHen i created it i just used the details view template, when i go to click on the textbox in the properties window under fields it just says (collection)
so how do i access each field's id value to set the validator to the right field?
0
 
LVL 29

Accepted Solution

by:
QPR earned 1000 total points
ID: 20422626
Are you using visual studio 2005? if so, select the details view in design mode and then click the smart tag and choose edit fields. Select the field in question and select convert this into a template. Close this dialogue box and then reopen it but this time choose edit templates. Your control label/textbox/whatever will now be shown as a single entity rather than the details view as a whole. Highlight the control and then give it an id in the properties window
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 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