Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8738571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:45:38+00:00 2026-06-13T10:45:38+00:00

Code language = VB. ASP.NET 4.0 I have a formview control on my page

  • 0

Code language = VB. ASP.NET 4.0

I have a formview control on my page defaulted to insert mode so when the page loads the only thing you can do is insert a records. I have a bound dropdownlist that defaults to the value of “none”..This can be classified as leave type.. Then I have next to that a textbox classified as hours..

I want to validate that is someone enters time for the textbox that they must choose a value from the dropdownlist.

once I get this far, I then have to repeat it threee times, So I would like to find a way to also write the control either grouping or referencing multiple controls.

If txtbox1.text > 0 then dropdownlist1.selected value must be >0

I could possibly get close just starting there but I find working in asp with the formview control a bit difficult to actually find the control. I have to use the following statements to work with any controls which is a pain
directcast(formview1.findcontrol(“textbox1”), textbox).text

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:45:39+00:00Added an answer on June 13, 2026 at 10:45 am

    To make it easier: do something like this:

    With formview1
        Dim txtbox1Value as string = directcast(.findcontrol("textbox1"),textbox).Text
        Dim dropdownlist1Value as string = directcast(.FindControl("dropdownlist1"), DropDownList).SelectedValue
        if txtbox1Value > "0" Then
           if dropdownlist1Value <= "0" Then
               ' Error
           End If
           If dropdownlist1Value >= "100" Then
               ' Another error
           End If
        End If
        ' etc.
    End With
    

    The idea: get all the values you need to test in a convenient form up front, then implement your logic. This will make your logic simpler because you won’t be distracted by the finding-and-casting you have to do.

    Actually, you could wrap all that in the ServerValidate event of a CustomValidator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What is the 'page lifecycle' of an ASP.NET WebForm? I have studied
I do have some strings that contains programming code, like XHTML (asp.net markup), C#,
I have few controls on asp.net web form page and i want to link
If I have a single label on my ASP.NET (2.0) page, and I want
Language: asp This is sample of my code: str = www.example.com/gotobuy.aspx?id=1234 key_word = .obuy.
While adding two language code files i.e. C# and VB.NET to App_Code, got an
I am writing some Natural Language Processing code and want to have a binary
I have an ASP.NET MVC 3 site using a custom route for specifying the
I'm using ASP.NET with C# 2.0. I have created some objects for a database
We are planning on adding multi-language support for our ASP.NET Website. I understand the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.