Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

EditTemplate controls inaccessible in CustomValidator servervalidate event handler

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Aamir Ghanchi - 01 Oct 2007 22:11 GMT
Like thr subject line says. I get no intellisense in VS 2005 as well
as get the compilation message "The name 'ddlCourse1' does not exist
in the current context".
Is there a way to have access to the controls being validated in the
EditTemplate of gridview.
The CustomValidator control itself is outside the gridview, but I have
tried putting it in a template column of gridview alongside with Edit/
Update linked buttons but to no avail.

I have akready scoured the newsgroup for the solutions, but found ni
similar topics.

Any leads will be aappreciated.

Thanks.
Aamir Ghanchi - 02 Oct 2007 17:17 GMT
> Like thr subject line says. I get no intellisense in VS 2005 as well
> as get the compilation message "The name 'ddlCourse1' does not exist
[quoted text clipped - 11 lines]
>
> Thanks.

Answering my own post with solution:
The issue had more to do with referencing the controls that are in the
EditemItemTemplate than it has to do with the CusotmValidator itself.
such controls are not directly available and have to be referred
through the GridViewRow being and calling its FindControl method with
the ID of the control you need.

//In the CustomValidator's ServerValidate event handler
//Get reference to the row being edited
GridViewRow editedRow = GridView1.Rows[GridView1.EditIndex];

//Get reference to the course dropdownlists
DropDownList ddlCourse1 =
(DropDownList)editedRow.FindControl("ddlCourse1");

//now use ddlCourse1 variable as you normally would use a control.

Cheers!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.