Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to force user to select values from the dropdownlist

Posted on 2008-10-17
11
Medium Priority
?
385 Views
Last Modified: 2012-05-05
Experts
I have managed to show date of birth in 3 different dropdownlist for day month and year

It looks something like attached with its default value.

How can I make sure that the user has changed the values in other words force the user to give his birth date by chosing some values.

meaning the date should not be " 1feb 1980"

please can someone advise
thanks
kay
screenshot.jpg
0
Comment
Question by:learningnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 6

Expert Comment

by:mirzas
ID: 22739287
Put a blank item in each of the dropdowns. It should be first and selected by default.
Later you can validate if the selection is blank which would mean the user did not change anything
or validate if it contains something, then the selection has been made.
0
 
LVL 7

Expert Comment

by:maXXXeE
ID: 22739310
IMHO, It is better to have the first entry as a blank value. (eg: <asp:ListItem Value="" Text="select"/>)

Because you can easily use validators to check the values are empty or not.
0
 
LVL 9

Assisted Solution

by:HeoQue
HeoQue earned 600 total points
ID: 22739410
1sty you need to put some initial values , like "-day-, -month-, -year-" with values all 0

then use a CutomValidor to validate the 3 dropdownlist to non-0 values !

customvalidtors usage :http://aspnet.4guysfromrolla.com/articles/073102-1.aspx
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:learningnet
ID: 22739435
thanks for your comments folks...

i am trying to use one of the existing class to push data into the date of birth control

without changing FillDropDownList procedure, i tried to add as per your suggestion below ...however, the one i have added is not getting displayed in the drop down ...


<asp:DropDownList ID="lstDayOfYourBirth" runat="server">
                                                                   <asp:ListItem Value="" Text="select" Selected=True/>
                                                                   </asp:DropDownList>

please can you advise

thanks
If Not Page.IsPostBack Then
                    WebFunctions.FillDropDownList(lstYearOfYourBirth, 1890, Year(Now))
                    WebFunctions.FillDropDownListMonths(lstMonthOfYourBirth)
                    WebFunctions.FillDropDownList(lstDayOfYourBirth, 1, 31)
                End If
 
 
 Public Shared Sub FillDropDownList(ByVal lst As DropDownList, ByVal first As Integer, ByVal last As Integer)
        Dim i As Integer
 
        lst.Items.Clear()
        For i = first To last
            lst.Items.Add(New ListItem(i, i))
        Next
    End Sub

Open in new window

0
 
LVL 9

Expert Comment

by:HeoQue
ID: 22739460
That's another issue, please posted on a new thread
0
 
LVL 7

Accepted Solution

by:
maXXXeE earned 800 total points
ID: 22739482
add this in code behind

lst.Items.Add(New ListItem("Select","");

after line14
0
 
LVL 6

Expert Comment

by:mirzas
ID: 22739496
It should be after line 11
0
 
LVL 6

Expert Comment

by:mirzas
ID: 22739499
It is not displayed because you clear the items,
lst.Items.Clear()

Open in new window

0
 

Author Comment

by:learningnet
ID: 22739512
thanks maXXXeE:

because this function FillDropDownList is been used in different places i really do not wanted to touch this ...

perhaps  i can make one for my use ...

is there no way i can add or over write this on the aspx page?

thanks for your help
0
 
LVL 6

Assisted Solution

by:mirzas
mirzas earned 600 total points
ID: 22739528
Create a custom version.

And add

lst.Items.Add(New ListItem("Select","");

after line 11
0
 
LVL 7

Expert Comment

by:maXXXeE
ID: 22739595
well if it is not possible for u to change the filldropdown methods,

call a function

If Not Page.IsPostBack Then

InitializeDropDowns(lstYearOfYourBirth,lstMonthOfYourBirth,lstDayOfYourBirth)  ' this is function , add you

                    WebFunctions.FillDropDownList(lstYearOfYourBirth, 1890, Year(Now))
                    WebFunctions.FillDropDownListMonths(lstMonthOfYourBirth)
                    WebFunctions.FillDropDownList(lstDayOfYourBirth, 1, 31)



                End If


Inside the function u need to add the values to dropdown


Public Shared Sub FillDropDownList(ByVal lst1 As DropDownList,ByVal lst2 As DropDownList,ByVal lst3 As DropDownList)
lst1.Items.Add(New ListItem("Select","");
lst1.SelectedItem.Value="";

lst2.Items.Add(New ListItem("Select","");
lst2.SelectedItem.Value="";

lst3.Items.Add(New ListItem("Select","");
lst3.SelectedItem.Value="";


end sub





Mind the syntax i am not good at vb, i do only c#. But hope u get the point
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question