Question

I have two listitems and the postback and run a function.

<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>

And it runs the function 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

I need to find out which one is checked and then change the text of a label depending on that.

The code I have doesn't work i don't think .Checked works in this instance.

Any idea of how to get the value or text of the listitem?

Thanks

Was it helpful?

Solution

If Me.ccsw.SelectedIndex = 0 Then
   lblPayText.Text = "Payment Amount = £" & Session("strTotal_DebtCharge")
Else
   lblPayText.Text = "Payment Amount = £" & Session("strTotal_Debt")
End If
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top