vb.net DropDownList绑定后数据重复
代码如下<scriptrunat="server">SubPage_Load(SenderAsObject,EAsEventArgs)DimtheYearAsnewArr...
代码如下
<script runat="server">
Sub Page_Load(Sender As Object,E As EventArgs)
Dim theYear As new ArrayList
Dim theMonth As new ArrayList
Dim i As Integer
For i = 1950 To 1992
theYear.Add(i.ToString())
Next
For i = 1 To 12
theMonth.Add(i.ToString())
Next
DYear.DataSource = theYear
DYear.databind()
DYear.Items.Insert(0,new ListItem("请选择",""))
DMonth.DataSource = theMonth
DMonth.databind()
DMonth.Items.Insert(0,new ListItem("请选择",""))
End Sub
</script>
<tr>
<td>出生年月 <font color="#CC0000">*</font></td>
<td> <asp:DropDownList AppendDataBoundItems="true" ID="DYear" runat="server" />
年
<asp:DropDownList AppendDataBoundItems="true" ID="DMonth" runat="server" />
月</td>
</tr>
问题是显示出来的年份和月份都有重复,请教各位老师!谢谢!
我爱领袖:
我测试了一下,不行啊
错误提示:
编译器错误信息: BC30451: 未声明名称“flase”。
改成“false”也不行。 展开
<script runat="server">
Sub Page_Load(Sender As Object,E As EventArgs)
Dim theYear As new ArrayList
Dim theMonth As new ArrayList
Dim i As Integer
For i = 1950 To 1992
theYear.Add(i.ToString())
Next
For i = 1 To 12
theMonth.Add(i.ToString())
Next
DYear.DataSource = theYear
DYear.databind()
DYear.Items.Insert(0,new ListItem("请选择",""))
DMonth.DataSource = theMonth
DMonth.databind()
DMonth.Items.Insert(0,new ListItem("请选择",""))
End Sub
</script>
<tr>
<td>出生年月 <font color="#CC0000">*</font></td>
<td> <asp:DropDownList AppendDataBoundItems="true" ID="DYear" runat="server" />
年
<asp:DropDownList AppendDataBoundItems="true" ID="DMonth" runat="server" />
月</td>
</tr>
问题是显示出来的年份和月份都有重复,请教各位老师!谢谢!
我爱领袖:
我测试了一下,不行啊
错误提示:
编译器错误信息: BC30451: 未声明名称“flase”。
改成“false”也不行。 展开
2个回答
展开全部
Sub Page_Load(Sender As Object,E As EventArgs)
if IspostBack=flase then
Dim theYear As new ArrayList
Dim theMonth As new ArrayList
Dim i As Integer
For i = 1950 To 1992
theYear.Add(i.ToString())
Next
For i = 1 To 12
theMonth.Add(i.ToString())
Next
DYear.DataSource = theYear
DYear.databind()
DYear.Items.Insert(0,new ListItem("请选择",""))
DMonth.DataSource = theMonth
DMonth.databind()
DMonth.Items.Insert(0,new ListItem("请选择",""))
end if
End Sub
添加IspostBack=false
============================
flase写错了,是False
if IspostBack=flase then
Dim theYear As new ArrayList
Dim theMonth As new ArrayList
Dim i As Integer
For i = 1950 To 1992
theYear.Add(i.ToString())
Next
For i = 1 To 12
theMonth.Add(i.ToString())
Next
DYear.DataSource = theYear
DYear.databind()
DYear.Items.Insert(0,new ListItem("请选择",""))
DMonth.DataSource = theMonth
DMonth.databind()
DMonth.Items.Insert(0,new ListItem("请选择",""))
end if
End Sub
添加IspostBack=false
============================
flase写错了,是False
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询