2010-11-11 117 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