vb.net 在创建数据集后,DropDownList数据重复 20
代码如下:<scriptrunat="server">SubPage_Load(SenderAsObject,EAsEventArgs)ifIspostBack=fals...
代码如下:
<script runat="server">
Sub Page_Load(Sender As Object,E As EventArgs)
if IspostBack=false 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
</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>
以上代码经检验无误,但当我加入数据集后,则DropDownList里的数据就有重复,我用的是Dreamweaver编辑,请注意,我已加了“if IspostBack=false then ”,但只要一加入数据集,问题就出现了。
数据集是这样的:
<MM:DataSet
id="DataSet1"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_Cnnjob") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_Cnnjob") %>'
CommandText='<%# "SELECT * FROM geren_yh WHERE Email = ?" %>'
Debug="true"
>
<Parameters>
<Parameter Name="@Email" Value='<%# IIf((Not Session("email") Is Nothing), Session("email"), "") %>' Type="WChar" />
</Parameters>
</MM:DataSet>
请各位老师指教,谢谢! 展开
<script runat="server">
Sub Page_Load(Sender As Object,E As EventArgs)
if IspostBack=false 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
</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>
以上代码经检验无误,但当我加入数据集后,则DropDownList里的数据就有重复,我用的是Dreamweaver编辑,请注意,我已加了“if IspostBack=false then ”,但只要一加入数据集,问题就出现了。
数据集是这样的:
<MM:DataSet
id="DataSet1"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_Cnnjob") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_Cnnjob") %>'
CommandText='<%# "SELECT * FROM geren_yh WHERE Email = ?" %>'
Debug="true"
>
<Parameters>
<Parameter Name="@Email" Value='<%# IIf((Not Session("email") Is Nothing), Session("email"), "") %>' Type="WChar" />
</Parameters>
</MM:DataSet>
请各位老师指教,谢谢! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询