.NETGURU
NOT ANSWERED: Validators
Messages   Related Types
This message was discovered on ASPFriends.com 'aspng-validators' list.


John Tyson
-----Original Message-----
From: John Tyson
Sent: Friday, May 17, 2002 7:59 AM
To: 'aspngfreeforall'
Subject: RE: [aspngfreeforall] RE: Passing of variables between ASP.Net
pages

Hi,

I have an asp:DropDownList which is populated by a datareader. Once a
selection is made from the DropDownList, a second control on the page is
populated based on the value selected in the DropDownList. I have
AutoPostBack set to True and an onSelectedIndexChanged procedure
attached to the DropDownList.

My problem is that I have a CompareValidator control validating that
"Select a Product" is not the value selected in the DropDownList,
otherwise it writes an error message to the ValidationSummary that the
user must select an option from the DropDownList. Once the user selects
an option from the DropDownList the error is removed. However, I have a
number of other controls for the user to populate and a submit button to
save the record. When the user clicks the submit button, the
CompareValidator reports an error on the DropDownList, even if an option
has been selected. Why does this happen, and how can fix this?

Any help would be appreciated. Thank you.
Reply to this message...
 
    
Kirk Jackson

Hi John,

For a drop-down list, I use a RequiredFieldValidator, rather than a
compare validator. This means that it checks that there is a _value_ for
the currently selected item. As every item has a databound value from
the datareader, that value will be there for any valid selection.

To add the item at the top of the list, I add an item to the drop-down
list, with a blank value:

dropDown.Items.Add(new ListItem("Select a product", ""));

Then the RequiredFieldValidator isn't valid if the first option is
chosen.

Hope that helps,

Kirk

-----Original Message-----
From: John Tyson [mailto:Click here to reveal e-mail address]=20
Sent: Tuesday, 21 May 2002 2:47 a.m.
To: aspng-validators
Subject: [aspng-validators] NOT ANSWERED: Validators

Subject: RE: [aspngfreeforall] RE: Passing of variables between ASP.Net
pages =3D20 Hi, =3D20 I have an asp:DropDownList which is populated by =
a
datareader. Once a selection is made from the DropDownList, a second
control on the page is populated based on the value selected in the
DropDownList. I have AutoPostBack set to True and an
onSelectedIndexChanged procedure attached to the DropDownList. =3D20 My
problem is that I have a CompareValidator control validating that
"Select a Product" is not the value selected in the DropDownList,
otherwise it writes an error message to the ValidationSummary that the
user must select an option from the DropDownList. Once the user selects
an option from the DropDownList the error is removed. However, I have a
number of other controls for the user to populate and a submit button to
save the record. When the user clicks the submit button, the
CompareValidator reports an error on the DropDownList, even if an option
has been selected. Why does this happen, and how can fix this? =3D20 =
=3D20
Any help would be appreciated. Thank you.=3D20 =3D20 =3D20

Reply to this message...
 
    
John Tyson
Hi Kirk,

Thanks for the response. Actually turns out my problem was using the
CompareValidator to compare to the text "Select from below" instead of
the value ("0"). Once I changed that it works great.

Thanks,

John

-----Original Message-----
From: Kirk Jackson [mailto:Click here to reveal e-mail address]=20
Sent: Monday, May 20, 2002 2:43 PM
To: aspng-validators
Subject: [aspng-validators] RE: NOT ANSWERED: Validators

Hi John,

For a drop-down list, I use a RequiredFieldValidator, rather than a
compare validator. This means that it checks that there is a _value_ for
the currently selected item. As every item has a databound value from
the datareader, that value will be there for any valid selection.

To add the item at the top of the list, I add an item to the drop-down
list, with a blank value:

dropDown.Items.Add(new ListItem("Select a product", ""));

Then the RequiredFieldValidator isn't valid if the first option is
chosen.

Hope that helps,

Kirk

-----Original Message-----
From: John Tyson [mailto:Click here to reveal e-mail address]=20
Sent: Tuesday, 21 May 2002 2:47 a.m.
To: aspng-validators
Subject: [aspng-validators] NOT ANSWERED: Validators

Subject: RE: [aspngfreeforall] RE: Passing of variables between ASP.Net
pages =3D20 Hi, =3D20 I have an asp:DropDownList which is populated by =
a
datareader. Once a selection is made from the DropDownList, a second
control on the page is populated based on the value selected in the
DropDownList. I have AutoPostBack set to True and an
onSelectedIndexChanged procedure attached to the DropDownList. =3D20 My
problem is that I have a CompareValidator control validating that
"Select a Product" is not the value selected in the DropDownList,
otherwise it writes an error message to the ValidationSummary that the
user must select an option from the DropDownList. Once the user selects
an option from the DropDownList the error is removed. However, I have a
number of other controls for the user to populate and a submit button to
save the record. When the user clicks the submit button, the
CompareValidator reports an error on the DropDownList, even if an option
has been selected. Why does this happen, and how can fix this? =3D20 =
=3D20
Any help would be appreciated. Thank you.=3D20 =3D20 =3D20

| [aspng-validators] member Click here to reveal e-mail address =3D YOUR ID
| http://www.aspfriends.com/aspfriends/aspng-validators.asp =3D =
JOIN/QUIT

Reply to this message...
 
 
System.Web.UI.MobileControls.CompareValidator
System.Web.UI.MobileControls.RequiredFieldValidator
System.Web.UI.MobileControls.ValidationSummary
System.Web.UI.WebControls.CompareValidator
System.Web.UI.WebControls.DropDownList
System.Web.UI.WebControls.ListItem
System.Web.UI.WebControls.RequiredFieldValidator
System.Web.UI.WebControls.ValidationSummary




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification