循环遍历datalist以获取数据

时间:2010-02-03 03:38:37

标签: asp.net vb.net

我坚持转换数据主义者的费率。我的页面包含一个下拉列表(货币转换器),一个数据列表 - 里面包含标签中行李的价格。现在我使用dropdownlist.selectedIndexchange

Protected Sub ddl_rate_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl_rate.SelectedIndexChanged
 Dim lbl_rate As Label = roomList.Items.Item(0).FindControl("lbl_rate")
 Dim a As Integer = Convert.ToInt32(lbl_rate.Text)
  If ddl_rate.Text = "Australia Dollars (AUD)" Then
            Dim b As Integer = (a * 0.8029)
            lbl_rate.Text = b.ToString()

        ElseIf ddl_rate.Text = "Brazil Reais (BRL)" Then
            Dim b As Integer = (a * 1.3024)
            lbl_rate.Text = b.ToString()
 End If

虽然它确实转换了费率,但它只转换了第一行。 有什么建议吗?

1 个答案:

答案 0 :(得分:0)

这是猜测而没有看到其余的代码:

Protected Sub ddl_rate_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl_rate.SelectedIndexChanged

  foreach(c as Control in roomList.Items)

    Dim lbl_rate As Label = c.FindControl("lbl_rate")
    Dim a As Integer = Convert.ToInt32(lbl_rate.Text)
    If ddl_rate.Text = "Australia Dollars (AUD)" Then
            Dim b As Integer = (a * 0.8029)
            lbl_rate.Text = b.ToString()

        ElseIf ddl_rate.Text = "Brazil Reais (BRL)" Then
            Dim b As Integer = (a * 1.3024)
            lbl_rate.Text = b.ToString()
    End If
 next