DropDownList绑定后数据重复

sykkys 2008-10-20 10:50:04
代码如下
<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>

问题是显示出来的年份和月份都有重复,请教各位老师!谢谢!
...全文
75 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sykkys 2008-10-20
  • 打赏
  • 举报
回复
这位大哥,不行啊
qinhl99 2008-10-20
  • 打赏
  • 举报
回复
放在if(!IsPostback)里面
sykkys 2008-10-20
  • 打赏
  • 举报
回复
郁闷,没有老师帮我解决吗
sykkys 2008-10-20
  • 打赏
  • 举报
回复
加这行
DYear.DataValueField = theYear
也不行。
:(
lunber 2008-10-20
  • 打赏
  • 举报
回复
DYear.DataValueField = theYear
加这行呢

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧