Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2004, 07:39 AM
Authorized User
 
Join Date: Feb 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding Required Field Validator to Datagrid

I want to add a Required Field Validator to a Datagrid Edit Item. I know i could do this using a template column but i forgot to add this functionality in at the start so if i could just add the functionality to the existing boundcolums dynamically or in some other way it would be great.

The onyl way i have tried so far is to try and add the control when i fire a sub from the OnItemDataBound event of the datagrid.

the sub i fire contains the following code

If (E.Item.ItemType = ListItemType.EditItem) Then
            Dim rqdTitle As New RequiredFieldValidator

            E.Item.Cells(3).Controls.Add(rqdTitle)
            rqdTitle.ControlToValidate = (E.Item.Cells(1).Controls(0).ID)
            rqdTitle.Text = "*"

        End If

E.Item.Cells(1).Controls(0).ID is the textbox xontrol in the edit item on the datagrid which i want to validate.

When i click edit on an item i get the "The ControlToValidate property of '' cannot be blank. " so its obviously not seeing the control i want to validate.

As i say i would rather not go through changing all my required fields into template columns, so if there is a way to do it to a databound it would be great to know,
cheers








Similar Threads
Thread Thread Starter Forum Replies Last Post
required field validator rocksbhavesh ASP.NET 1.0 and 1.1 Basics 2 June 30th, 2007 03:20 AM
Required Field Validator RGB ASP.NET 1.0 and 1.1 Basics 3 March 31st, 2006 03:31 PM
Required Field Validator to a datagrid editt item dfalconer Classic ASP Basics 4 September 6th, 2004 03:34 PM
Required Field Validator to a datagrid editt item dfalconer ASP.NET 1.0 and 1.1 Professional 9 September 2nd, 2004 02:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.