473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

EditTemplate controls inaccessible in CustomValidator servervalidate event handler

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.

Oct 1 '07 #1
1 2151
On Oct 1, 4:11 pm, Aamir Ghanchi <aamirghan...@gmail.comwrote:
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.
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!

Oct 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: George Ter-Saakov | last post by:
Hi. I am fighting the CustomValidator strange behavior for second day already. I created some test project which is only to reproduce the problem. 1. I created UserControl which has an only a...
1
by: Paul | last post by:
Hi, I'm developing a search facility for my web app. In order for the search criteria to be valid the user must (a) enter some text in a text box and check and least one checkbox (of which there...
5
by: Gene McCrory | last post by:
Is it possible to have a CustomValidator against two controls in an EditItemTemplate on a DataGrid? Case: Have a business rule that states if ATextBox starts with "ACertainValue" then BTextBox...
2
by: Stephen Miller | last post by:
Can the CustomValidator be used to simply report unexpected errors, without requiring Client/Server validation? To explain, say you had a simple text box and button that did a Full-text Search of a...
1
by: Martin | last post by:
Hi, Because I need this validation without a postback occuring, I call Page.Validate from the Page.Load event handler. The corresponding ServerValidate event handler is called, and as this...
10
by: Nathan Sokalski | last post by:
I have a DataList control with an EditTemplate. Three of the controls in this template include a Calendar, a Button with CommandName="update", and a Button with CommandName="cancel". Whenever I...
0
by: antonyliu2002 | last post by:
The full code is pasted below. It looks scarily long, but it's pretty simple. It is adapted from a sample code at MSDN. If you run it, and check it out from your browser, you'll see: ...
0
by: webmaster | last post by:
I've been playing around with asp.net 2.0/vs.net 2005/C# 2005 - I had a few noob questions. 1. Is there a setting that sets all current and future controls on a page to position absolutely...
3
by: Eric Layman | last post by:
Hi, Are there ways for customvalidator to have 2 different error messages? eg: i have 2 conditions to check using customvalidator depends on condition, i would need to return 2 different...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.