如何显示radiobuttonlist中的选定值

时间:2012-04-07 20:31:26

标签: asp.net vb.net radiobuttonlist

我试过

Dim theme = rblTheme.Items(rblTheme.SelectedIndex).Value

获得第一个值

Dim theme = rblTheme.SelectedItem.Value

获得第一个值

Dim theme = ""
        For i As Integer = 0 To rblTheme.Items.Count - 1

            If (rblTheme.Items(i).Selected) Then
                theme = rblTheme.Items(i).Value
            End If
        Next

选择两个值。

需要帮助!!

1 个答案:

答案 0 :(得分:0)

 Dim selectedItemVal as string
 selectedItemVal=rblTheme.SelectedValue;

我猜你再次在页面回发中重新加载RadioButton列表(当你点击某个按钮时)。所以你可能应该移动该代码如果isPostBack属性为false

 protected void Page_Load(object sender, EventArgs e)
 {
     if(!IsPostBack)
     {
        //Your code to load the Radio button list control
     }
 }

现在您应该可以获得按钮点击事件的值。

相关问题