2010-11-11 123 views
0

我有兩個listitems和回發並運行一個函數。獲得listitem在回發上的價值

<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在這種情況下工作。

有關如何獲取listitem的值或文本的任何想法?

感謝

回答

1
If Me.ccsw.SelectedIndex = 0 Then 
    lblPayText.Text = "Payment Amount = £" & Session("strTotal_DebtCharge") 
Else 
    lblPayText.Text = "Payment Amount = £" & Session("strTotal_Debt") 
End If