代码之家  ›  专栏  ›  技术社区  ›  Jamie Taylor

回发时获取列表项的值

  •  0
  • Jamie Taylor  · 技术社区  · 14 年前

    <asp:RadioButtonList runat="server" CssClass="ccsw" ID="ccsw" AutoPostBack="true" RepeatDirection="Horizontal" OnSelectedIndexChanged="UpdateCharges">
        <asp:ListItem Text="Credit Card"></asp:ListItem>
        <asp:ListItem Text="Debit Card"></asp:ListItem>
      </asp:RadioButtonList>
    

    UpdateCharges

    Sub UpdateCharges(ByVal sender As Object, ByVal e As System.EventArgs)
    
    If ccsw_1.Checked Then
    
        lblPayText.Text = "Payment Amount = £" & Session("strTotal_DebtCharge")
    
    Else
    
        lblPayText.Text = "Payment Amount = £" & Session("strTotal_Debt")
    
    End If
    
    End Sub
    

    我需要找出哪一个被选中,然后根据它更改标签的文本。

    我的代码不起作用我想 .Checked

    知道如何获取列表项的值或文本吗?

    谢谢

    1 回复  |  直到 14 年前
        1
  •  1
  •   Tim Schmelter    14 年前
    If Me.ccsw.SelectedIndex = 0 Then
       lblPayText.Text = "Payment Amount = £" & Session("strTotal_DebtCharge")
    Else
       lblPayText.Text = "Payment Amount = £" & Session("strTotal_Debt")
    End If