为注册系统创建下拉列表 [英] creating drop down list for a registration system
本文介绍了为注册系统创建下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在注册系统中,输入出生日期是创建下拉列表的常见做法.
但这需要花时间在月"下拉列表中写下每个月的名称,并在代码中写下年"下拉列表的年列表.
我们不能创建函数来生成注册系统的年月列表吗?
In registration system, for entering date of birth it is a common practice to create a drop down list.
But it''s a time taking to write down every months name in the month drop-down list, write down the list of years for the year drop-down list in the code.
Can''t we create a function which generates the list of years and the months for the registration system?
推荐答案
是的.您可以选择创建年,月,日的XML文件,然后将其绑定到下拉列表.
Yes. you can have another option of Create XML file of year, month, day and then bind it to dropdownlist.
嗨...请参见下面的链接.
http://www.roseindia.net/javascript/javascript-calendar.shtml [ ^ ]
或在源页面中使用它
hi... see the below link.
http://www.roseindia.net/javascript/javascript-calendar.shtml[^]
or use this in source page
<input id="demo1" type="text" size="25"><a href="java<!-- no -->script:NewCal('demo1','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
Dim type As String = ""
Dim intialvalue As Integer
Dim finalvalue As Integer
Dim d As Integer
Dim m As Integer
Dim y As Integer
Dim dt As DataTable
Dim row As DataRow
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
With DD
.DataSource = getData_table("Day", 1, 31)
.DataTextField = "Name"
.DataValueField = "ID"
.DataBind()
End With
With MM
.DataSource = getData_table("Month", 1, 12)
.DataTextField = "Name"
.DataValueField = "ID"
.DataBind()
End With
With YYYY
.DataSource = getData_table("year", 1950, 2001)
.DataTextField = "Name"
.DataValueField = "ID"
.DataBind()
End With
Result.Text = DD.SelectedItem.Value.ToString & "/" & MM.SelectedItem.Value.ToString & "/" & YYYY.SelectedItem.Value.ToString
End Sub
Public Function getData_table(ByVal type As String, ByVal intial_value As Integer, ByVal final_value As Integer) As DataTable
dt = New DataTable
dt.Columns.Add("ID")
dt.Columns.Add("Name")
Try
row = dt.NewRow
row("ID") = "0"
row("Name") = type
dt.Rows.Add(row)
For i = intial_value To final_value
row = dt.NewRow
row("ID") = final_value
row("Name") = intial_value
dt.Rows.Add(row)
intial_value = intial_value + 1
final_value = final_value - 1
Next
Catch ex As Exception
End Try
Return dt
End Function
这篇关于为注册系统创建下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文